With N=3 and W=2, a client sends a write and gets a timeout error. One replica stored the value and the other two never received it. What can a later read return, and what should the client do?
Sketch your own answer first, then compare it with the one below.
A strong answer
The client does not know whether its write happened, and the system cannot say either. The write reached one replica, short of W=2, so it was not acknowledged. But nothing rolls it back. That replica keeps the value.
A later read with R=2 asks two replicas. If it includes the replica with the value, it returns the new value, taking it as the newest version. Read repair may then copy it to the others, so the write that was reported as failed becomes permanent. If the read skips that replica, it returns the old value. Either result is legitimate, and the answer can change between reads.
So the client should treat the timeout as unknown, not as failure. Retrying is safe only if the write is idempotent: setting a key to a value, or carrying a unique request id the store uses to discard duplicates, can be repeated. An increment cannot.
This is one of the ways a quorum store differs from a single database with transactions. A quorum protects reads against missing acknowledged writes. It does not make a failed write disappear.
Sources
- Martin Kleppmann (2017). Designing Data-Intensive Applications.
- Giuseppe DeCandia and others (2007). Dynamo: Amazon's Highly Available Key-value Store.