Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Improving Leaderless Replication with Read Repair, Anti-Entropy, Sloppy Quorums, and Hinted Handoff

Hello. In the previous lesson, you saw how leaderless replication uses , , and : if

a successful write quorum and a later read quorum must overlap. That overlap lets the reader encounter an up-to-date replica, provided it can correctly interpret version metadata.

That reasoning leaves an operational question: replicas can still miss writes because nodes fail, networks partition, or responses time out. This lesson examines the mechanisms that bring replicas back into sync—and the availability-oriented technique that deliberately relaxes the “same replica set” assumption behind strict quorums. By the end, you should be able to distinguish read repair, anti-entropy, hinted handoff, and sloppy quorums, and explain both their benefits and limits.


Replication is usually incomplete in the short term

Consider a key replicated on nodes A, B, and C, with and . A client writes version of the key. A and B acknowledge the write, while C is temporarily unreachable.

The write succeeds because two acknowledgments meet the write quorum. But the physical state is now uneven:

Replica Stored version
A
B
C , stale

A later quorum read can still discover , because it must receive two responses and therefore cannot avoid both A and B. However, C remains stale. If it stays stale indefinitely, failures later could reduce durability, and reads made under weaker settings might return old data.

Leaderless systems therefore need convergence mechanisms: ways to ensure that missed updates eventually reach the replicas that should store them. Read repair and anti-entropy address this directly. Hinted handoff accelerates recovery from temporary failures, while sloppy quorums prioritize write availability when the normal replica set cannot be reached.


Read repair: heal inconsistency when it is observed

A read repair occurs during a normal read. The coordinator asks several replicas for a key, compares their returned versions, selects the current value according to the system’s versioning and conflict-resolution rules, and sends that value to replicas found to be stale.

In the example above, suppose a read receives:

  • A:
  • C:

The coordinator returns to the client. It can also issue a repair write to C so that C stores . The ordinary read has therefore done two jobs: served the application and reduced replica divergence.

The important qualification is “according to version metadata.” A replica can be identified as stale only if the system can establish that one version supersedes another. With concurrent writes, version vectors or other causal metadata may reveal that two versions conflict rather than that one is simply old. Read repair cannot infer an application’s intended merge by itself.

Google SWE teaches systems design | EP4: Leaderless Replication

Watch “Google SWE teaches systems design | EP4: Leaderless Replication” from Jordan has no life for a compact visual treatment of why replicas diverge and how a read can repair them.

Watch repair mechanisms. Focus on the distinction between a background synchronization process and repair triggered by a read. Treat the version-number example as an intuition: real systems need metadata that can distinguish an older version from a concurrent conflicting one.

Read repair has an appealing property: the repair is focused precisely on data that applications are actively using. It may also make a fresh value more likely to be observed on later reads, since more replicas now contain it.

But it has a major blind spot. A key that is rarely read may remain stale for a very long time. A node that was offline for several days can miss a large number of updates without any of those keys being read after the node recovers. For this reason, read repair is useful but insufficient as the only convergence mechanism.

Some systems perform repair before replying to the client; others reply first and repair asynchronously. The former can provide stronger behavior for particular read modes, but adds latency. The essential idea is unchanged: a read discovers disagreement and propagates the selected current version to stale responders.


Anti-entropy: repair all data in the background

Anti-entropy is a background replica-synchronization process, independent of application reads. Replicas periodically compare the data they are both responsible for, identify differences, and transfer the missing or outdated records.

Where read repair is opportunistic and demand-driven, anti-entropy is systematic:

Mechanism Trigger Best at repairing Main limitation
Read repair A client read detects disagreement Frequently read keys Cold data may never be repaired
Anti-entropy Periodic background work All keys, including rarely read data Uses background network, CPU, and disk resources

A naïve implementation would exchange every key and value between replicas, but that would be expensive. Dynamo’s influential design uses Merkle trees to compare large key ranges efficiently.

A Merkle tree is a hierarchy of hashes:

  1. Each leaf represents a small range of keys and stores a hash summarizing its contents.
  2. Each parent stores a hash derived from its children’s hashes.
  3. The root hash summarizes the entire range.

If two replicas have equal root hashes for the same range, their contents match for the purposes of the hash comparison. If their roots differ, the replicas compare child hashes, descending only into branches that differ. Eventually they isolate the small leaf ranges—and then the individual keys—that need synchronization.

A binary Merkle tree summarizes successive key ranges with hashes: replicas compare root hashes first, then descend only into branches whose hashes differ, narrowing repair to inconsistent ranges rather than transferring every record.

This hierarchy makes anti-entropy practical for large datasets: most matching data does not need to be transmitted or read in detail. It is still an eventual process, however. Until a repair cycle runs and completes, a recovered replica may remain behind.

Dynamo: Amazon's Highly Available Key-value Store

Read the relevant parts of the original Dynamo paper. They connect all four mechanisms in one concrete design: availability during failures, temporary placement of replicas, background synchronization, and repair discovered while serving reads.

Start with Section 4.6, “Handling Failures: Hinted Handoff.” Read the sloppy-quorum rationale, paying attention to the distinction between the intended preference list and the healthy nodes that actually accept a write. Then read Section 4.7, “Handling permanent failures: Replica synchronization.” Follow the Merkle-tree explanation. Focus on why matching root hashes avoid unnecessary transfer, and why differing hashes lead replicas to inspect only smaller divergent branches. Finally, in the later “Implementation” discussion, read the read-repair passage. Notice that Dynamo uses late responses to repair replicas that missed an update, complementing rather than replacing anti-entropy.

Read repair and anti-entropy are therefore complementary:

  • Read repair rapidly heals records encountered by real workloads.
  • Anti-entropy provides coverage for records that workloads do not happen to touch.
  • Neither mechanism removes the need for a conflict-resolution rule when writes are concurrent.

Hinted handoff: preserve a missed write for a temporarily unavailable replica

Now return to the earlier example in which C is down. A hinted handoff records the fact that C should have received a write but did not.

A healthy node—often the coordinator or another replica—stores the write along with a hint, metadata identifying C as the intended destination. When C becomes reachable again, the hint holder attempts to deliver the missed write to C. After confirmed delivery, the temporary hint can be removed.

A client sends row K to coordinator A. A replicates the row to B, but C is down, so A records a hint identifying C as the intended recipient; after C recovers, A can forward the missed write.

Hinted handoff is especially effective when failures are transient: a node is briefly unreachable because of maintenance, a restart, or a short network disruption. Rather than waiting for a full anti-entropy cycle, the system has an explicit backlog of updates to replay to that node.

However, a hint is not a permanent replacement for the intended replica:

  • The hint holder itself can fail before delivery.
  • A long outage may outlast hint-retention policies.
  • If the cluster changes membership substantially, the intended placement may change.
  • The node may have missed data beyond what survives in the hint backlog.

For these reasons, anti-entropy remains necessary even in systems that support hinted handoff.

There is also an important distinction that is often blurred:

Hinted handoff is a delivery mechanism. Sloppy quorum is a rule for which nodes may count toward a successful quorum.

A system can use hinted handoff without allowing temporary holders to satisfy the requested consistency level.

For example, Apache Cassandra uses hinted handoff, but not Dynamo-style true sloppy quorums. If a Cassandra write requests QUORUM consistency and too few intended replicas are available, the write fails even if a hint can be recorded. The hint helps a replica catch up after a successful write; it does not turn an unavailable primary replica into a successful quorum acknowledgment.


Sloppy quorums: accept writes outside the normal replica set

A strict quorum obtains its write acknowledgments and read responses from the key’s intended set of replicas. This is the model assumed by the condition:

A sloppy quorum relaxes strict membership during a failure. If one or more intended replicas are unreachable, the coordinator continues through a broader preference list and writes to healthy substitute nodes. Those substitutes can count toward the write quorum.

Suppose the intended replicas for a key are A, B, and C, and the system uses:

If B and C are unreachable, a strict quorum cannot complete a write: only A is available from the intended three replicas. With a sloppy quorum, the coordinator may write to A and substitute node D. D stores the value with a hint indicating that B or C was the intended replica. The write can now obtain two acknowledgments and succeed.

When B or C recovers, D forwards the temporarily held replica to its intended destination. That later transfer is the hinted handoff.

Sloppy quorum improves write availability and can preserve a durable copy somewhere in the cluster during an outage. In the extreme case, a configuration with can accept a write so long as any suitable healthy node can persist it.

But this availability comes at a precise consistency cost: the simple quorum-overlap proof no longer necessarily applies.

Under a strict quorum, the write and read sets are both subsets of the same intended replicas. Under a sloppy quorum, a write may be acknowledged by A and D, while a later read—after B and C recover—may consult B and C. The sets can be disjoint:

Operation Nodes contacted Contains new value?
Sloppy write A and substitute D Yes
Later ordinary read B and C Possibly no, before handoff
Post-handoff read B and C Yes, after synchronization

Thus, even if the configuration nominally uses and with , the strict condition

does not guarantee that the later reader encounters the completed write. The acknowledgments were obtained from a broader set than the intended replica set.

This is why DDIA emphasizes that sloppy quorums are primarily an availability mechanism, not a guarantee of read-after-write consistency. A system deliberately accepts temporary uncertainty in where the durable copies reside, then uses hinted handoff and anti-entropy to restore normal placement and convergence.


A compact decision framework

When you encounter one of these mechanisms in a design, ask four questions.

  1. How was a replica found to be stale?
    If a client read exposed the mismatch, it is read repair. If a scheduled background comparison exposed it, it is anti-entropy.

  2. Where is the missing write held?
    If it is retained temporarily with metadata naming an unavailable intended node, it is hinted handoff.

  3. Does the temporary holder count toward write success?
    If yes, the system is using a sloppy quorum. If no, it may still be using hints but retains strict quorum membership.

  4. What restores the intended placement?
    Hinted handoff handles a known, temporary missed delivery. Anti-entropy supplies broader eventual coverage, including cases hints cannot repair.

The mechanisms form a layered strategy rather than competing alternatives. Read repair catches divergence where it matters now. Hinted handoff quickly replays known missed writes. Anti-entropy makes eventual convergence comprehensive. Sloppy quorums keep the system accepting writes during failures, but temporarily weaken the clean freshness reasoning available with strict quorums.


Key takeaways

Leaderless replication accepts that replicas may diverge temporarily and relies on repair mechanisms to converge later.

  • Read repair compares versions during a read and updates stale replicas that participated in that read. It is useful but does not fix data that is never read.
  • Anti-entropy periodically synchronizes replicas in the background. Merkle trees make large-scale comparison efficient by locating only the divergent key ranges.
  • Hinted handoff stores a missed write temporarily, with metadata identifying its intended replica, and forwards it when that replica recovers.
  • Sloppy quorums let healthy nodes outside the normal replica set count toward a write quorum, improving write availability during failures.
  • Hinted handoff and sloppy quorum are related but distinct: a system may use hints without treating them as quorum acknowledgments.
  • Because sloppy-quorum writes can be stored outside the normal replica set, the strict-quorum argument based on

no longer by itself guarantees that a later ordinary read will observe the write.

This completes the replication chapter. Next, the course turns to partitioning: how systems divide data across machines, beginning with the trade-offs between range-based and hash-based partitioning.

Can't find a good explanation? Sign up and we'll make it for you

Sign up