/articles/crdt-tombstones

← Back to blogs
Article

The Hardest Problem in Distributed Deletions: Proving It's Safe to Forget

How do CRDTs garbage-collect tombstones, and how is that different from Cassandra?

·6 min read

Recently, I went down a rabbit hole regarding how distributed systems handle deletions. I initially thought the hard part was propagating the delete across the network. I was wrong.

The real, fundamental question is actually this: How can a replicated system prove that deleting the tombstone itself is safe?

That single architectural diff between systems like Cassandra and CRDT-based systems.


1. The Memory of Deletion (Why Tombstones Exist)

Imagine three replicas: A, B, and C. All hold a record X.

If A receives a DELETE X command and simply erases X from its disk, it now holds nothing. When B and C eventually sync with A, the system has zero evidence that X was intentionally deleted. Worse, if C was offline during the delete, it will wake up, sync its X with A, and resurrect the dead data.

A tombstone is the memory of the deletion. It tells the cluster, "X existed, and we intentionally killed it."

But keeping that memory forever causes unbounded storage bloat. So, the difficult question becomes: When can we safely forget the memory?


2. Cassandra : The Operational Time Bound

Cassandra solves this using an operational time window called gc_grace_seconds (defaulting to 10 days).

The lifecycle looks like this:

  1. DELETE X is issued.
  2. A tombstone is written.
  3. The system waits for gc_grace_seconds.
  4. During the next compaction, the tombstone is physically purged.

Why wait 10 days? Because a replica might have been offline. Cassandra’s core assumption is: Any offline replica will recover and be repaired via anti-entropy within this 10-day window.

It’s crucial to note that this is an operational assumption. If a node stays down for 11 days, misses the repair window, and then wakes up, its old X will look like valid new data, and the zombie will resurrect. (Modern Cassandra does offer safeguards like only_purge_repaired_tombstones to trade storage space for stricter safety, but the time-based premise remains).


3. CRDTs: Causal Stability

CRDTs approach this entirely differently. Instead of asking, "Has enough time passed?", a CRDT asks: "Can any replica still produce an operation that makes this tombstone relevant?"

This is where causal stability comes in.

Using version vectors or replica progress tracking, a CRDT tracks exactly what every replica has observed. If Replica A deletes X at version 10, the system waits until it can mathematically prove that Replicas A, B, and C have all advanced past version 10.

Once the deletion enters the causally stable past, no known replica can ever send an older, conflicting operation. Only then is the tombstone garbage-collected.

  • Cassandra asks: "Has my safety window elapsed?"
  • CRDTs ask: "Has my deletion entered the causally stable past?"

4. Trade-Off: Why Not Just Use Causal Stability Everywhere?

At first, causal stability seems vastly superior. It’s precise! But here is the distributed-systems catch I realized: Causal stability requires heavy metadata and coordination.

Imagine a CRDT replica goes offline forever. If your rule for GC is "every replica must see the delete," the causal frontier freezes. The offline node blocks the entire cluster from garbage-collecting anything, leading to infinite metadata bloat. To fix this, causal systems require complex membership management to safely evict dead nodes from the cluster.

Cassandra, designed for massive scale and high availability, rejects this complexity. It chooses cheap, local timestamp metadata over global causal tracking. It essentially says: "I don't need a perfect causal proof. I'll just retain the deletion long enough for our operational repair scripts to do their job."


5. CRDT Trap: Structural Dependencies

I found another subtle trap. Let’s say your CRDT achieves causal stability. Does that automatically mean you can delete the tombstone from memory?

Not always. It depends on the data structure.

In a simple OR-Set, yes. But consider a Sequence CRDT (used for collaborative text editing). Imagine the sequence: A → B → C. If B is deleted, it becomes a tombstone: A → [B tombstone] → C.

Even if B's deletion becomes causally stable, C might still hold internal metadata saying, "My predecessor is B." If you physically erase B from memory to save space, you break C's structural anchor.

Sequence CRDTs require complex structural rules like re-parenting identifiers before a causally stable tombstone can actually be dropped. Causal stability is necessary for CRDT GC, but not always sufficient.


6. 3 Layers of Deletion

If you are designing or studying distributed systems, I highly recommend visualizing deletions in these three distinct layers:

Rendering diagram...

Takeaway

gc_grace_seconds and causal stability are not competing consistency algorithms. They are two fundamentally different ways of establishing the condition under which layer 3 (Physical GC) can happen.

Cassandra answers with a time-bounded operational assumption, optimizing for massive scale and availability. Causally tracked CRDTs answer with a mathematical proof, optimizing for precise, coordinator-free merging.

Wow ! you read till the end, finds interesting ? Then u and me are in same team.

835 words left