Skip to main content

The Delete That Came Back: Tombstones and Distributed Deletion

· 11 min read
Clustron Team
Distributed Systems Engineering

Deleting a key on a single server is the easiest operation it performs. Free the memory, drop the index entry, and the key is simply gone — there is nothing left to be inconsistent about. Replication takes that triviality and turns it into the single hardest write the system has to make, because the moment there is more than one copy, "the key is gone" becomes a fact that has to reach every copy, and the absence of data is remarkably hard to communicate. A present value can be shipped across the wire; an absence has nothing to ship.

Here is the failure in full. A client deletes key user:42. The delete reaches two of the three replicas, which dutifully remove it. The third replica is down and misses the delete entirely, and when it recovers it still holds the old value. Later a background anti-entropy pass compares the three replicas and finds a disagreement: two of them have nothing for user:42, one of them has a value. Which is newer? A value carries a version; an absence carries nothing to compare it against. So the repair concludes the value-holding replica is the one with data worth propagating, pushes it back to the other two, and user:42 is alive again — on every replica. The delete did not fail. It was quietly undone by the recovery it was meant to outlive.

The root problem is that a naive delete destroys the very evidence that the delete happened. You cannot out-vote a stale value with nothing; a missing key loses every argument against a present one. The fix is to stop treating deletion as the removal of data and start treating it as the writing of data — a write whose payload is a small marker that says this key is dead as of version T. That marker is a tombstone, and the rest of this post is about why it is necessary, what it costs, and the one rule that keeps it honest.

A delete is a versioned write​

A tombstone replaces removal with a record. Instead of erasing user:42, the delete writes a marker in its place, stamped with the same per-key version or hybrid logical clock that any ordinary write carries. Now reconciliation has something to compare, because the delete is no longer an absence — it is a value that happens to mean "gone," and it sits at a version later than the value it replaced.

Replay the failure with tombstones in place. The two replicas that saw the delete hold tombstone@v2; the recovered replica still holds user:42@v1. The repair pass compares versions exactly as it compares any conflict — v2 > v1, newest wins — and the tombstone propagates to the lagging replica, overwriting its stale value. All three converge on "deleted." The read path, when it assembles a quorum of responses and finds the winning version is a tombstone, returns not found. A quorum delete is nothing more than a quorum write of a tombstone, so R + W > N gives deletion the same guarantee it gives any write: a read that reaches a quorum is guaranteed to see the tombstone and report the key gone.

No tombstone — nothing carries a version, so the stale copy winsR1 · —R2 · —R3 · v1deleteddeletedwas down → kept v1repair: absence has no version → v1 propagates back → key resurrectedTombstone — the delete is a versioned write that out-votes the old copyR1 · †v2R2 · †v2R3 · v1tombstonetombstonewas down → v1†v2 > v1 → tombstone wins → R3's value removed, the delete holdsthe dagger marks a tombstone: a record that means "gone," not an absence

You cannot keep tombstones forever​

Trading removal for a record is not free, and the bill comes due in two currencies. The first is space: every delete now leaves a marker behind, so a workload that churns keys — a cache with heavy turnover, a queue whose entries are created and consumed, a session store with constant expiry — accumulates tombstones without bound if nothing ever clears them. A key that has been written and deleted a thousand times should not cost a thousand markers.

The second currency is read latency. A read or a range scan has to step over tombstones to find live data, because a tombstone is a record the scan encounters and must evaluate before discarding. A range that is mostly deleted becomes a range the reader wades through, paying for keys that are not there — the pathological version is a scan that reads a million tombstones to return a handful of live values. Deletion that was supposed to reclaim resources ends up taxing the very reads that come after it.

So tombstones have to be garbage-collected: after enough time has passed, the marker is physically purged and its space reclaimed. The question is how long "enough" is — and that interval is not a tuning preference, it is a correctness constraint.

The grace period is a race against repair​

Purging a tombstone makes a claim: every replica has seen this delete, so the marker is no longer needed to defend it. If that claim is false — if some replica still holds the pre-delete value and has not yet received the tombstone — then purging the tombstone removes the only record that would have beaten that stale value. The next repair pass finds the stale value with no opponent, and it resurrects, exactly as it would have with no tombstone at all. Garbage-collecting too early reopens the wound the tombstone was created to close.

The defense is a grace period: a tombstone may be purged only once it is older than the maximum time a delete could take to reach every replica. That bound is set by how often anti-entropy repair runs, which is why the rule of thumb pairs them — the tombstone grace period must comfortably exceed the repair interval, so that every replica is guaranteed to have reconciled the delete before its marker disappears.

// A delete is a write whose value is a tombstone, versioned like any other.
Put(key, new Tombstone { Version = hlc.Now() }); // not Remove(key)

// Reconciliation treats the tombstone as an ordinary versioned record:
var winner = candidates.MaxBy(c => c.Version);
return winner.IsTombstone ? NotFound : winner.Value; // newest wins, even when "newest" means gone

// GC may purge a tombstone only once it is older than the grace period —
// and grace MUST exceed the repair interval, or a lagging replica resurrects the value.
if (now - tombstone.Version.Time > gcGrace) // gcGrace > maxRepairInterval
PhysicallyRemove(key);

The same rule has a sharp operational edge: a replica that has been down longer than the grace period must not simply rejoin. While it was gone, deletes may have been applied, propagated, and had their tombstones purged — so the returning node carries values whose tombstones no longer exist anywhere, and letting it reconcile would push those zombies back into the cluster. The safe move is to treat such a node as empty and rebuild it from the surviving replicas rather than let its stale state participate in a repair. Down briefly, reconcile; down too long, wipe and refill.

Expiry is the same problem wearing a clock​

Time-to-live deletion is the tombstone problem with a timer attached. When a key expires, its disappearance has to reach every replica just as a manual delete does — and a replica that misses the expiry, or whose clock lags, will happily serve the stale value until something corrects it. That is why expiry in a replicated store is usually implemented as a tombstone with a time trigger rather than a silent drop: the expiry writes a versioned marker so that the removal propagates and out-votes any copy that has not yet expired on its own. An expiring key that leaves no record behind resurrects for exactly the same reason a naively deleted one does.

Wrap-up​

Deletion is the one write where doing the obvious thing — removing the data — is wrong, because it destroys the evidence that the delete occurred and leaves an absence that cannot out-argue a surviving copy. A tombstone fixes this by making deletion a versioned write: a marker stamped later than the value it replaces, which propagates and wins through the same last-write-wins reconciliation that settles every other conflict, so the delete reaches the replicas that missed it instead of being undone by them. The cost is space and read latency, paid down by garbage-collecting old tombstones — but only after a grace period that must outlast the repair interval, because purging a tombstone before every replica has seen it hands the stale value an uncontested comeback. Get the grace period right and deletes stay deleted; get it wrong, or rejoin a long-dead node without a rebuild, and you will meet the delete that came back.