Try
↑ ↓ move↵ openesc close

Interview prep / Quorums

Mid · Quorums · System design interview question

A Cassandra-style cluster had one node offline for twelve days. After it returned, rows that had been deleted last week started reappearing. Explain the mechanism and how to avoid it.

Sketch your own answer first, then compare it with the one below.

A strong answer

A delete in a leaderless store is a write of a marker, a tombstone, since the replicas that missed the delete must be able to learn about it. Tombstones cannot be kept forever, so they are dropped after a grace period. In Cassandra that is gc_grace_seconds, ten days by default.

In this story the node was down when the deletes were made. The other replicas stored the tombstones, and after ten days they discarded them. The returning node still holds the old values. To the cluster, a value with no tombstone anywhere looks like a perfectly valid row that the other replicas somehow missed. Repair or read repair copies it back to them. The deleted rows are resurrected.

Prevention is operational. Run repair on every node more often than the grace period, so tombstones always reach all replicas before they are dropped. A node that has been down for longer than the grace period should not just be started up. Either run a repair before it serves reads, or wipe it and rebuild it from the other replicas. Hints will not help here, since they are only kept for a few hours by default.

Lowering the grace period shrinks the window for tombstones to spread, so it makes the problem worse unless repair runs more often too.

Sources

Learn it by running it

The quorums lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms