Concept
Quorum Reads and Version Resolution
Reads in Dynamo are more complex than writes because replicas can be stale. A write that succeeded with W=2 might not have reached the third replica. When a read later contacts that stale replica, it must know to prefer the fresher value.
Version Numbers
Dynamo uses vector clocks (covered in Track 3) to version values. For this task we simplify: each value has a monotonically increasing integer version. Higher version = newer value.
Read Protocol
def read(key, replicas, R):
responses = []
for replica in replicas:
if replica.is_up():
responses.append(replica.get(key)) # (version, value)
if len(responses) < R:
return "FAIL"
best = max(responses, key=lambda r: r.version)
return best.value
The Consistency Guarantee
With N=3, W=2, R=2: any 2 of the 3 replicas we read must include at least one that acknowledged the write (since both quorums have size 2, they must overlap in a 3-node set). So we always see the latest write — even if one replica is stale.
Read Repair (Preview)
After returning the best value, Dynamo should update the stale replica in the background. This is read repair — it's how data eventually converges without requiring an explicit sync protocol. You will implement it in Track 3.
Sign in to run and submit code.