liveBook · Manning

Tombstone

As explained in Kafka for Architects

A tombstone message is a Kafka record with a non-null key and a null value that marks the keyed record for deletion during compaction.

A tombstone is a Kafka record with a non-null key and a null value. It marks the keyed record for deletion during log compaction. For example, when an account no longer exists, AccountService publishes the account number as the key and null as the value. section 2.5.1

Tombstones matter because deletion in a compacted topic has timing and delivery consequences:

  • Compacted topics require keys, and key-based partitioning keeps records for the same key in one partition. section 2.5.1
  • Compaction retains the latest value for each key, while a null-valued record is eventually removed as a deletion marker. section 2.5.2
  • Kafka retains tombstones uncompacted for the configured delete-retention period, allowing disconnected consumers time to observe deletions. section 2.5.2
  • Compaction is periodic rather than immediate, so consumers cannot treat a tombstone as an instant physical removal from the topic. section 2.5.4

Deleting an account and synchronizing a database

Suppose a compacted Balances topic contains a record for ACC-1447. AccountService publishes <ACC-1447, null> when the account is deleted. A connected consumer can process that tombstone; a JDBC sink connector interprets it as a delete for the matching database key. If a consumer was disconnected, tombstone retention helps it learn about the deletion after reconnecting. section 2.5.2 section 7.3.8

Figure 2.16 During the compaction process, the data within a topic is rewritten. For each key, only the latest value is retained, and messages where the value is null are deleted.
A screenshot of a computer

Description automatically generated

Use the compaction diagram to trace how the latest value survives for each key and how null-valued records represent deletions before being removed. section 2.5.2

How Kafka for Architects covers it

How deep it goes
Explains keyed records, compaction timing, retention, consumer catch-up, and database handling without detailing broker internals.
Examples
Uses account ACC-1447, Balances, AccountService, DashboardService, and JDBC sink deletion as concrete examples.
What it assumes
Assumes familiarity with Kafka records, keys, partitions, consumers, and log-compacted topics.
What you can do after
Apply it via Kafka to propagate keyed deletions through compacted topics and JDBC sink database integrations.
How it connects
Connects tombstones to log compaction, compacted topics, Kafka Connect, JDBC sink connectors, and database synchronization.

Also explained in

Compare how 3 books explain tombstone →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.