skip to content

A team building a Dynamo-style store advertises 'vector clocks' for conflict detection, but a reviewer says what they've actually implemented is a version vector, and that the distinction matters for correctness. What is the difference between a vector clock and a version vector in this context, and what unbounded-growth problem do both share in a system with many nodes or clients?

level: middleimportance: should knowfreq 40%

answer

  1. events vs updates
  2. one entry per source of concurrency
  3. same dominance comparison
  4. per-server entry hides concurrent writes
  5. growth follows the writer population

basics

~20 s

A vector clock counts every event of every process; a version vector counts only updates to stored data. Correctness turns on who gets entries: per server, concurrent writes through one server can overwrite each other; per client, it grows with clients.

solid answer

~50 s

A **vector clock**, in its original sense, orders every event of a computation, sends and receives included; a **version vector** (1983, five years older) versions replica states: it counts only updates, and replicas compare and merge vectors when they synchronize. A store that counts writes in (node, counter) pairs has built version vectors, whatever it calls them; Dynamo's paper calls its lists 'vector clocks'. The correctness point is whose entries the vector holds: it tracks causality accurately only with an entry per source of concurrent updates. With one entry per server, a second client's concurrent write through the same server appears to dominate the first, and the first is silently lost. An entry per client avoids that but grows with every client that ever writes the key, and entries per server grow with node churn. Pruning bounds either, at the cost of accuracy.

go deeper

for a junior

Should know both terms describe a vector of counters compared entry by entry to detect conflicting writes, and that the vector grows with the number of parties that get an entry.

for a middle

Should be able to state that a vector clock counts every event while a version vector counts only updates, and that entries per replica keep the vector small but can let concurrent writes through one replica look ordered.

for a senior

Should be able to explain the unbounded-growth failure mode concretely, including node churn, describe at least one mitigation (pruning, capping, coarser entries) and say what accuracy each one gives up.

for a principal

Should be able to choose and justify an entry scheme (per client, per server, dotted) for a specific system's writer-churn profile, and design the pruning policy for cluster topology changes.

## Two mechanisms, one comparison rule Both mechanisms are compact encodings of a **causal history**, the set of events that could have influenced a state. Each keeps one counter per participant, and both compare two vectors the same way: A precedes B if every counter in A is ≤ the corresponding counter in B and at least one is strictly less; if neither precedes the other, the two are **concurrent**. What differs is which events get counted: | | Vector clock | Version vector | |---|---|---| | Tracks | the happened-before order of events among communicating processes | the versions of replicated data | | Counts | every event: local steps, sends and receives | only the updates that change a replica | | Merges | on every message received, then counts the receive itself as a new event | when replicas synchronize; merging two concurrent updates into one version counts as a new update | | Introduced | around 1988 | in 1983 | A store that keeps (node, counter) pairs counting writes, compares them on reads and merges them on reconciliation is using version vectors. Amazon's Dynamo paper is the well-known example of the looser usage: it calls its lists of (node, counter) pairs 'vector clocks'. In casual engineering talk the two names stand in for each other, which is harmless only while everyone means the same mechanism. ## Why the reviewer says it matters for correctness A vector tracks causality accurately only if it has an entry for every **source of concurrency**, every party that can update the data concurrently. In a get/put store the sources are the clients (and any server that updates the data itself); the servers only register the clients' writes. So who gets an entry is a correctness choice, not only a size choice: - **One entry per server.** A client reads a version and later writes; the server that takes the write increments its own entry. If a second client, having read the same version, writes through the same server, its write gets that server's next counter, and its vector **appears to dominate** the first client's write, though neither saw the other. The first write is then silently replaced: a last-writer-wins at that server, hidden inside a mechanism advertised as detecting conflicts. The dotted-version-vectors paper (2010) works through this case and notes that Dynamo, with one entry per replica node, falls into it. Keeping both versions does not rescue it either, because the server has no vector it could give the second write that records it as concurrent with the first. - **One entry per client.** Every concurrent writer has its own counter, so concurrent writes stay concurrent and are kept. The price is size. - **Dotted version vectors** keep entries per server and attach to each version the single event (a 'dot') that created it, which tracks concurrent clients accurately with vectors the size of the number of servers that store the key. ## The growth problem both share Whatever the scope, a vector has one entry per participant it tracks, so its size follows the population of writers, not the data: | Vector keyed by | What happens to its size | |---|---| | a server or replica | stays near the number of servers that coordinate writes to the key, and grows when servers are added, replaced or step in for failed ones | | a client identity | grows with every distinct client that has ever written to the key: with millions of mobile devices, or stateless workers whose identity rotates, a hot key can accumulate thousands of stale entries | The vector is attached to and transmitted with every read and write of the object, so growth inflates network and storage cost per operation and can dwarf the payload. Dynamo's paper reports the server-side form: its vector clocks can grow when many servers coordinate the writes to an object, which happens under network partitions or multiple server failures. ## Bounding it, and what that costs 1. **Pruning or truncation.** Dropping entries bounds the vector. Dynamo stores a timestamp with each (node, counter) pair and, once a clock reaches a threshold (say 10 pairs), removes the oldest pair. The paper states the cost: descendant relationships can no longer be derived accurately. A version whose entry was dropped may no longer dominate its ancestor, so the two look concurrent and the stale one comes back as a conflict to resolve; the paper adds that the problem had not surfaced in its production use. 2. **Coarser entries.** One entry per server, or per datacenter, keeps the vector small, at the accuracy cost above: concurrent writes that share an entry look ordered. 3. **Housekeeping on topology change.** Entries of servers that no longer write stay in every vector they touched until removed, and removing one that a live version still depends on is pruning, with the same cost. Unmanaged growth shows up gradually in production: latency creeping up on hot keys, storage growing faster than the data, and, where a hard cap starts truncating silently, false conflicts between writes that had in fact superseded each other.

  • If Dynamo calls its metadata 'vector clocks' but scopes it per coordinator node, why does the distinction still matter to a reviewer?
    Because the name hides what the scope costs. Counting writes per node is a version vector, and with one entry per node, two clients writing concurrently through the same node get vectors that look ordered, so one write is silently lost while the store believes it detects every conflict. The reviewer is asking where the concurrency comes from: per-node entries are accurate only when no two concurrent writes share a node.
  • What happens if you scope a version vector per-replica but replicas get added and removed frequently (e.g., in an auto-scaling cluster)?
    Every replica that ever coordinated a write leaves an entry in the vectors it touched, so entries of decommissioned replicas become dead weight unless the system removes them. Removing one is pruning: safe only once no live version still needs that entry to prove it descends from another, otherwise a stale version can look concurrent and return as a conflict. Skip the housekeeping and a supposedly bounded vector still grows with node churn, just more slowly than with client churn.
  • Could you avoid the growth problem entirely by scoping the vector per data-center or per shard instead of per node?
    Not entirely. A per-datacenter entry keeps one entry per datacenter, but every write inside a datacenter now shares one counter, so writes there must be ordered by something else, such as a local leader; otherwise two concurrent writes in one datacenter look ordered and one is lost, the per-server problem one level up. The vector still grows as datacenters are added. It is a reasonable trade when cross-datacenter conflicts are what matter and each datacenter orders its own writes.

It's like logging a shared document's edits per regional office rather than per employee: the office log stays short, but when two employees in one office edit at once, the log shows one edit following the other, and nobody sees that they clashed.

  • Treats 'vector clock' and 'version vector' as never overlapping in real-world usage
  • Doesn't recognize that key scope (client vs replica) drives the growth problem
  • Assumes replica-scoped vectors can never grow
  • Unaware that pruning/truncation trades correctness for bounded size
  • Thinks keying entries per replica costs only debugging detail, not lost concurrent writes

context