Quick revision
The short answer
Quorums guarantee that a read overlaps the latest acknowledged write, not that a read-modify-write is atomic: two clients can read the same value, each compute a new one, and each write it at quorum, and last-write-wins by timestamp silently drops one, sometimes the newer one when client clocks are skewed. A safe compare-and-set needs one agreed order of operations per key, from a consensus protocol such as Raft per key range or a Paxos round per operation. It costs extra round trips and needs a majority, so it is offered as a separate operation, with CRDT counters for pure increments and a put with expected_version that returns a conflict.
What to remember
In this answer, we saw that quorums give overlap between reads and writes, not atomic read-modify-write, so two concurrent quorum updates both succeed and last-write-wins silently keeps one, possibly the older one under clock skew. A safe compare-and-set needs one agreed order per key, from Raft per key range or a Paxos round per operation, and costs extra round trips and a reachable majority, so it is a separate operation. Counters are better served by commutative increments or CRDT counters, and the client API makes the safe path explicit with put and expected_version returning a conflict for the caller to retry.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Quorums guarantee that a read overlaps the latest acknowledged write, not that a read-modify-write is atomic: two clients can read the same value, each compute a new one, and each write it at quorum, and last-write-wins by timestamp silently drops one, sometimes the newer one when client clocks are skewed. A safe compare-and-set needs one agreed order of operations per key, from a consensus protocol such as Raft per key range or a Paxos round per operation. It costs extra round trips and needs a majority, so it is offered as a separate operation, with CRDT counters for pure increments and a put with expected_version that returns a conflict.
Background to this question
This question catches many experienced engineers, because 'we write at QUORUM and read at QUORUM' sounds like it should be safe. The audit's 0.02 percent of lost updates shows it is not, and the reason teaches exactly what quorums promise. In this answer, we will recap the quorum guarantee, reproduce the lost update, see how clock skew makes it worse, add compare-and-set backed by consensus, look at its cost and the alternative for counters, and design an honest client API.
1A Quick Recap: What a Quorum Promises
In a leaderless store with N = 3 replicas, a QUORUM write waits for 2 acknowledgements and a QUORUM read asks 2 replicas. Because 2 + 2 > 3, any read overlaps at least one replica that holds the latest acknowledged write. When replicas disagree, the store keeps the value with the highest timestamp, a rule called last-write-wins (LWW).
That is the whole promise: a read sees the newest acknowledged write. It says nothing about two clients that read, compute and write concurrently. Each step is individually correct, but nothing ties a write to the value it was computed from.
2Reproducing the Lost Update
Two services increment an account's usage counter. Both read the current value, 100, at quorum. Each adds its own amount and writes back at quorum. Both writes are acknowledged by two replicas, so both callers believe they succeeded. But the replicas now hold two competing values, and LWW keeps the one with the later timestamp. The other update is gone without any error.
9 messages in order. Play them, or step through them one at a time.
Both writes succeed; the correct result, 108, never exists.
3How Clock Skew Makes It Worse
Last-write-wins uses timestamps set by the clients or coordinators, not a global order. Clocks on different machines drift, and NTP usually keeps them within a few milliseconds, sometimes much more after a bad sync. Suppose X really writes second, at 10:00:00.130 by true time, but its clock runs 20 ms slow and stamps 10:00:00.110. Y wrote first but stamped 10:00:00.125. LWW then keeps Y's older value and discards X's newer one.
So LWW does not even pick the latest update reliably; it picks the one with the larger timestamp. For counters and limits, where every update matters, that is the wrong tool.
4Adding a Safe Compare-and-Set
A compare-and-set (CAS), 'write this value only if the current version is still 17', needs every replica to agree on one order of operations for that key, so that exactly one of two competing CAS operations wins. That agreement is the job of a consensus protocol.
One design runs Raft per key range: each range of keys has a group of three replicas, one of which is elected leader. All writes for the range go through the leader, which assigns them an order in a replicated log and applies a put-if-version only if the version matches, atomically. A majority of the group must store each log entry before it commits. Stores such as CockroachDB, TiKV and etcd work this way. The other design keeps the store leaderless and runs a Paxos round for each conditional operation, as Cassandra does for its lightweight transactions: the replicas first agree that this operation may proceed, read the current value, and then commit the conditional write, which takes several round trips.
- Client sends put(k, v, expected=17)to the range's leader
- Leader appends to its logassigns position 9,041
- Majority of the group stored it?2 of 3 replicasYesCommit the entryNoWait or fail over
- Apply in log order: version still 17?only one competing CAS can winYesWrite, version 18NoReject with CONFLICT
4 steps in order. Play them, or step through them one at a time.
5What It Costs and When to Use Something Else
Consensus is not free. A CAS needs at least one extra round trip to a majority, often more in Paxos-per-operation designs, so its latency is several times a plain write's. And it needs a majority of the key's replicas to be reachable: during a partition that isolates two of three replicas, plain LWW writes may still succeed while CAS cannot.
So we offer it as a separate operation, used where correctness needs it, and keep plain puts fast for everything else. For counters there is a better path: commutative operations. An increment applied in any order gives the same total, so the store can accept increment(key, 5) rather than read-modify-write. A CRDT counter, a conflict-free replicated data type, keeps a per-replica count and merges by summing, so replicas can accept increments independently and never lose one.
| Need | Operation | Cost |
|---|---|---|
| Last value is fine to overwrite | plain put, LWW | one quorum round trip |
| Counter or usage total | increment, CRDT counter | one round trip, merges without loss |
| Limit check or unique claim | CAS through consensus | extra round trips, needs a majority |
6An Honest Client API
Finally, the API should make the safe path obvious. put(key, value, expected_version) returns a clear conflict error carrying the current version, and the caller retries by reading again, recomputing and trying once more. Callers that use plain put should know they are choosing last-write-wins.
7Follow-up questions
How do per-range Raft groups change what happens when a node fails?
Each key range has its own group of, say, three replicas. If the failed node was the leader for some ranges, the remaining two replicas of each such range notice the missing heartbeats and elect a new leader within a few seconds, so writes to those ranges pause briefly and then continue. Ranges whose leader was on another node are unaffected, and every range keeps working as long as a majority of its replicas is alive. The cluster then adds a replacement replica to each affected group through a membership change and sends it a snapshot plus the recent log, restoring three copies.
Is QUORUM plus a version column in the value enough?
No. Without consensus, two writers can both check the version, both find 17 and both write, because the check and the write are not atomic across replicas. The atomicity has to come from one agreed order.
Can we use a lock service instead?
A distributed lock around the read-modify-write can work, but it adds a dependency and is fragile when a lock holder pauses and its lease expires. Fencing tokens make it safer, but at that point a built-in CAS is simpler and more robust.
8Conclusion
In this answer, we saw that quorums give overlap between reads and writes, not atomic read-modify-write, so two concurrent quorum updates both succeed and last-write-wins silently keeps one, possibly the older one under clock skew. A safe compare-and-set needs one agreed order per key, from Raft per key range or a Paxos round per operation, and costs extra round trips and a reachable majority, so it is a separate operation. Counters are better served by commutative increments or CRDT counters, and the client API makes the safe path explicit with put and expected_version returning a conflict for the caller to retry.
Open with
Quorums only promise that a read overlaps the latest acknowledged write. They do not make read-modify-write atomic. Two clients can both read 100 at quorum, each compute a new value and each write it at quorum; both writes are acknowledged, then last-write-wins keeps the one with the later timestamp and the other update is silently lost.
Then, if they want more
Clock skew makes it worse, because the winner is chosen by timestamp, not real order, so the newer update can be discarded. To add compare-and-set, the replicas must agree on one order of operations per key.
I would run a consensus protocol like Raft per key range, so a leader orders writes and applies put-if-version atomically once a majority has the entry, or use a Paxos round per conditional operation like Cassandra's lightweight transactions.
That costs extra round trips and needs a majority available, so I would offer it as a separate operation and keep plain puts fast. For counters I would rather use commutative increments or CRDT counters that merge without loss.
And the API should be honest: put with an expected version returns a conflict error with the current version, and callers re-read and retry.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Why do quorum reads and writes not prevent these lost updates, and how would you add a...": https://scrivio-interview-library.netlify.app/architecture/system-design-problems/e99e1854b3/