Problem
Wall clocks drift, so timestamps cannot tell whether one update happened before another or concurrently. Resolving conflicts by timestamp drops writes. Replicas need a way to know when two versions are truly conflicting.
Also known as: version-vectors, logical-vector-clock
Track causal ordering of events across replicas so concurrent updates can be detected rather than silently overwritten.
Wall clocks drift, so timestamps cannot tell whether one update happened before another or concurrently. Resolving conflicts by timestamp drops writes. Replicas need a way to know when two versions are truly conflicting.
A vector clock is a per-version map from node identifier to counter that captures causality. It answers a question timestamps cannot: did this write see that earlier write, or did they happen independently? Dynamo and Riak used it to detect conflicting updates.
Each replica increments its own counter on a local update and takes the element-wise maximum when merging.
A writes: {A:1}
B reads, writes: {A:1, B:1} (descends from A's)
C reads {A:1}, writes: {A:1, C:1}
{A:1,B:1} vs {A:1,C:1}: neither dominates -> concurrent
client merges, writes {A:1,B:1,C:1,D:1}
Comparison rule: V1 precedes V2 when every counter in V1 is at most that in V2 and one is smaller. If neither precedes the other, both are kept as siblings. The reader receives all siblings plus the vector context and must send that context back with the merged write.
Extra metadata per record
Medium: sibling cleanup and pruning
High: causal reasoning
Sibling explosion when clients never merge
Pruned vector entries cause false concurrency or false ordering
Client writes without supplying context and creates unnecessary siblings