Sub topic 13
Surviving temporary failures with sloppy quorums and hinted handoff
This chapter assumes you know how consistent hashing builds a preference list of N replicas for each key. It also assumes you know how read and write quorums (R and W) work.
The problem with strict quorums
With N=3 and W=2, a write succeeds only if two of the key's three designated replicas acknowledge it. If a network blip or a restart makes two of them unreachable, writes for that key fail, even though the cluster has plenty of healthy nodes. For a store that promises to always accept writes, that is a poor trade.
Sloppy quorums
A sloppy quorum counts acknowledgments from the first N healthy nodes found while walking the ring, not only from the key's designated replicas. If a designated replica is down, the coordinator skips it and uses the next healthy node clockwise, which is a stand-in.
The stand-in is not the key's owner. It stores the write in a separate hints area, tagged with the intended owner. This mechanism is called hinted handoff. When failure detection (gossip) reports that the owner is back, the stand-in sends the data to it and deletes the hint.
A small simulation
class Node:
def __init__(self, name):
self.name = name
self.up = True
self.data = {}
self.hints = [] # (owner, key, value)
def sloppy_put(key, value, preferred, fallbacks, w):
acks = 0
spare = iter(fallbacks)
for owner in preferred:
if owner.up:
owner.data[key] = value
acks += 1
else:
stand_in = next(spare, None)
if stand_in is not None and stand_in.up:
stand_in.hints.append((owner, key, value))
acks += 1
return acks >= w
def handoff(node):
remaining = []
for owner, key, value in node.hints:
if owner.up:
owner.data[key] = value
else:
remaining.append((owner, key, value))
node.hints = remaining
a, b, c, d = (Node(n) for n in "abcd")
c.up = False
print(sloppy_put("user:42", "x", [a, b, c], [d], w=3)) # True
print(c.data) # {}
c.up = True
handoff(d)
print(c.data) # {'user:42': 'x'}A strict quorum with W=3 would have failed in this scenario. The sloppy version succeeds, and C catches up once it returns.
What you give up
A sloppy quorum weakens the overlap guarantee. R + W > N only guarantees that a read sees the latest write if both quorums come from the same N nodes. Here the write landed on D, which is outside the preference list. A read that contacts A, B, and C may miss it until the handoff completes. So a sloppy quorum is an availability feature, not a stronger consistency guarantee.
Common errors
- Assuming overlap holds during failures. Under sloppy quorums, R + W > N holds only when the preference list is healthy.
- Unbounded hints. If a node stays down for days, stand-ins accumulate hints without limit. Set a hint TTL and a size cap, and fall back to anti-entropy repair (the next chapter) for long outages.
- Losing the stand-in. If D fails before handing off, the write exists on fewer nodes than the coordinator reported. Treat hints as best-effort and rely on repair for durability.
- Handoff storms. A recovering node that receives hints from many peers at once can be overloaded. Throttle the replay rate.
Exercise
With N=3, W=2, a key's replicas are A, B, and C. A and B are down, and D and E are healthy and next on the ring. Does a strict quorum accept the write? Does a sloppy quorum? In the sloppy case, does a read at R=2 from A, B, and C reliably see it?
Show answer
A strict quorum fails, because only C is reachable and 1 < W=2. A sloppy quorum accepts the write: C, D (holding a hint for A), and E (holding a hint for B) acknowledge it. A read from A, B, and C reliably sees it only once the hints are handed off. Until then, the data sits on D and E, outside the preference list.