Data and Knowledge SystemsPermissions, identity and deletionPrincipal
When can tombstone retention make an old snapshot unsafe for index rebuilding?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
A stale snapshot contains document X, deleted later through a tombstone in a compacted Kafka topic. An index rebuild overlays the changes still available and resurrects X. Explain why compaction does not guarantee arbitrary snapshot recovery, investigate alternative causes, and design a retained snapshot/log handoff or source reconciliation before activation.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
A tombstone is a record of a deletion, but it does not promise infinite replay time. Kafka 4.3’s compaction documentation explains log compaction and says consumers need to reach the head before the tombstone retention interval to be guaranteed to see delete markers. A current compacted log can represent the live key set correctly while an index rebuilt from a separate, stale snapshot remains wrong if the delete fell outside its valid replay window. Check the actual topic cleanup and retention settings too. Do not assume that reading from offset zero, when the old history may already have been cleaned, repairs an arbitrarily old snapshot.
I would reconstruct the timeline with the source version and deletion time for X, snapshot high-water mark, Kafka partition and offset, tombstone production and retention, rebuild replay starting offset, and final index write. There are other plausible causes: the producer never emitted the tombstone, the key format changed between update and delete, or a stale event applied after the delete. The failure is not proven by the mere age of the snapshot. Find the exact missing transition and compare it against the authoritative source of current documents.
For a reliable rebuild, use a fresh source snapshot with a well-defined change boundary and replay changes from an offset retained since that boundary, or rebuild from a trustworthy current compacted view without mixing it with an older state. If neither guarantee is available, rescan the source or reconcile the rebuilt key set against authoritative current state before serving it. Keep deletion versions or durable negative state when the system needs to reject an older upsert during replay. An offset is meaningful per partition. The handoff from snapshot to log must account for keys moving and for duplicate delivery.
Would I extend tombstone retention forever? Usually no. Retention can buy enough time for the slowest supported bootstrap, but it is not a substitute for a bounded recovery contract and a measured rebuild duration. A bulk snapshot races the change stream deals with snapshot racing a live change stream. Here the snapshot can be much older than the replay guarantee. The document was deleted yesterday. Why is the assistant still quoting it? asks why a deleted document is still quoted in normal operation. This is a specific rebuild path that can reintroduce a delete after the live index had already removed it.
For a hypothetical timeline, snapshot S contains X, the source later deletes X, and retention eventually removes the tombstone. Replaying only the currently available changes over S does not necessarily remove its old X row. In contrast, constructing a new empty index from a complete, trustworthy current compacted state can omit X without needing the stale snapshot. These are different bootstrap protocols, even if both read the same topic.
The rebuilt generation must remain private until its completeness and source boundary are established. Reconcile identities and revisions against authoritative current state if the replay window cannot be proven. A correct result count is insufficient because a missing live document and a resurrected deleted document can cancel numerically. Kafka’s version selector is useful for finding the deployed release’s specific retention and compaction contract.
Related questions
Keep practising data and knowledge systems
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux