Kafka: log compaction never removes the last record for a key, including a tombstone

Compaction guarantees the most recent value per key survives. Deleting a key means writing a null value - a tombstone - and that tombstone is itself retained for delete.retention.ms so every consumer has a chance to see the delete.

Full code & output

This topic is available to PRO members.

Sign in Create a free account

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-25