Zum Hauptinhalt springen

Write It Down Somewhere: Hinted Handoff and the Sloppy Quorum

· 11 Minuten Lesezeit
Clustron Team
Engineering für verteilte Systeme

A write arrives for a key, and the key's replicas live on three specific nodes chosen by the placement scheme. One of those three is down — rebooting, GC-paused, or cut off by a flaky link. The strict response is to fail the write until the node is back, or to block waiting for it. Both answers hand the client a refusal that has nothing to do with the client: a machine it never knew about is unavailable, so its write cannot proceed. That is exactly backwards. The reason the data was spread across three nodes in the first place was to keep serving when one is gone; a write path that stalls on a single absent replica has discarded that resilience at the precise moment it was meant to earn its keep.

Hinted handoff is the technique that refuses to let one down node become a down write. When the coordinator cannot reach an intended replica, it does not drop the write and it does not wait. It sends the write to a different healthy node, attaching a hint: a small piece of metadata that says this value is not really yours — it belongs to node C, which was unreachable; hold it for them. The stand-in node stores the value in a separate holding area, acknowledges it, and the write succeeds. Later, when node C recovers, the stand-in notices, replays every hinted write it was keeping for C, and deletes its local copies once C confirms receipt. The outage became a deferred delivery instead of a failure.

The companion idea is the sloppy quorum. A strict quorum insists that the write be acknowledged by a majority of the specific replicas that own the key. A sloppy quorum relaxes that: it requires a majority of acknowledgements from whatever healthy nodes the coordinator can reach, hinted stand-ins included. The write still needs W acks, but those acks may come from nodes that are only temporarily holding the data. This post is about how the two fit together, what the sloppiness costs, and where the mechanism stops being enough.

The hint is a holding area, not a home​

The crucial detail is that a hinted write lives somewhere different from an ordinary one. When the stand-in node accepts a value destined for node C, it does not file it under its own keyspace as if it owned it — if it did, the cluster would now believe the stand-in is a legitimate replica for that key, and every later read and repair would be confused about who holds what. Instead the value goes into a dedicated hint store, tagged with the identity of the node it is meant for. The stand-in is a courier holding a parcel, not a new tenant.

That separation is what makes the cleanup safe. The stand-in watches membership — the same gossip and failure-detection signal the rest of the cluster uses — and when the intended node transitions back to alive, the stand-in drains its hints for that node: it replays each held write to the rightful owner, waits for an acknowledgement, and only then deletes the hinted copy. The parcel is delivered and the courier's shelf is cleared. Until that drain completes, a read for the key still works through the ordinary replicas and read-repair, because the hinted copy was never meant to serve reads — it exists only to be delivered.

A sloppy quorum keeps the write alive while C is down — D holds a hint until C returnsAowner · storedBowner · storedCowner · DOWNcoord.W = 2D (stand-in)hint → for CC unreachablewrite redirected to D with a hint — counts toward W, so the client gets its ackreplay when C returns, then deletethe hint is a parcel D is holding for C, not a new home — it never serves reads and is cleared on delivery

What the sloppy quorum trades away​

The availability is not free, and the honest way to describe hinted handoff is by what it gives up. A strict quorum has a clean property: because reads and writes both touch a majority of the same fixed set of replicas, any read quorum overlaps any write quorum, so a read is guaranteed to see the latest acknowledged write. The sloppy quorum breaks that overlap on purpose. A write that was acknowledged by two owners plus a hinted stand-in, and a read that reaches the two owners and the now-recovered-but-not-yet-drained third owner, can miss each other — the freshest copy is sitting in D's hint store, which the read does not consult.

So the consistency hinted handoff offers is weaker: it preserves durability of the write — the value is written down somewhere and will reach its owners — without preserving the read-after-write overlap that a strict quorum buys. In practice systems tune this with the familiar R and W knobs and lean on the read path's own healing: read repair fixes the staleness a read happens to catch, and background anti-entropy catches the rest, including keys the hint delivered to an owner that some concurrent read had already passed. Hinted handoff is an availability mechanism bolted onto an eventually-consistent store; it is not a way to keep a strict quorum strict.

// Coordinator write under a sloppy quorum with hinted handoff.
var owners = ring.ReplicasFor(key); // the N nodes that should hold this key
var acks = 0;
foreach (var node in owners) {
if (await TryWrite(node, key, value)) { acks++; continue; }

// Owner unreachable: hand the write to the next healthy node, tagged for the owner.
var standIn = ring.NextHealthy(excluding: owners);
await standIn.StoreHint(forNode: node, key, value); // separate hint store, NOT standIn's keyspace
acks++; // the hint counts toward W (sloppy)
}
return acks >= W; // W acks, some possibly hinted

// Background on the stand-in: drain hints when the owner is alive again.
onMemberAlive(node => {
foreach (var h in hintStore.For(node))
if (await node.Replay(h)) hintStore.Delete(h); // deliver, confirm, then clear
});

When hints cannot drain​

The mechanism has a failure mode that is important to name, because it is the one that quietly undoes the benefit. Hints only help if the down node comes back. If node C is not rebooting but permanently dead — disk gone, instance terminated — then its stand-in accumulates hints that will never be delivered, and those hints are not a repair: they are a growing pile of data stranded on a node that was never meant to own it. Every store that uses hinted handoff therefore bounds it: a cap on how long a hint is retained, or how much hint data a stand-in will hold, after which the hints are dropped and the system falls back on the durable path.

That durable path is the one from the membership and recovery posts. A node that stays down past the hint window is not waited for; it is declared gone, and its share of the keyspace is rebuilt onto a fresh replica from the surviving owners, with anti-entropy reconciling anything the hints could not. This is the same discipline that governs tombstones: a grace window long enough to cover the common transient case, and a hard fallback to full reconciliation when the window is exceeded, so a short outage is cheap and a long one is survivable — just not free. Hints buy time; they do not replace the mechanism that makes a permanently lost node recoverable.

Wrap-up​

Hinted handoff exists so that one temporarily unreachable replica does not become a refused write. When an owner is down, the coordinator routes the write to a healthy stand-in with a hint identifying the real owner; a sloppy quorum counts that stand-in toward the acknowledgement, so the client succeeds; and the stand-in holds the value in a separate hint store and replays it when the owner returns, then clears it. The trade is explicit: the write stays durable and available, but the strict read-write quorum overlap is given up, which is why the read path's repair and background anti-entropy have to stand behind it. And hints are a bridge, not a guarantee — they are bounded in time and size, and a node that stays gone past that bound is rebuilt from its replicas rather than waited for forever. Keep one node's bad minute from becoming every client's failed write; let the slower machinery handle the node that is not coming back.