HerokuTom CrayfordIncident / postmortem
Pulling the Thread on Kafka’s Compacted Topics
Summary
Apache Kafka’s log cleaner for compacted topics could crash silently when its offset map lacked enough space to hold a full log segment. Because the broker continued running without that internal thread, superseded data accumulated, threatening node and potentially cluster stability. The post explains compaction’s two phases: building an offset map for newer messages, then rewriting segments while retaining the latest offset for each key, with the latest segment excluded from the map. Kafka was changed to remove the crashing assertion and track partial segment loads so cleaning can recover without fitting an entire segment in memory. The roughly 100-line patch shipped in Kafka 0.10.1.1, which the post identifies as Heroku’s default version, and prevents the cleaner from dying silently.
Context
Kafka’s log cleaner thread could run out of offset-map space while processing a segment, triggering an assertion and crashing without notifying an operator. The broker continued running, allowing data intended for compaction to grow and threatening node or cluster stability.
Approach / What changed
The fix removed the assertion that killed the cleaner and reworked internal tracking to record partial segment loads. The cleaner can therefore recover from where it stopped instead of requiring a whole segment to fit in the offset map.
Takeaways
Compacted topics retain the newest message for each key, using periodic cleaning and optional time-based retention; duplicate keys may remain until cleaning completes.
Kafka’s cleaner builds an offset map for new messages, then rewrites older segments while removing messages whose offsets are lower than the mapped offset.
The fix was committed to Kafka and released in version 0.10.1.1, allowing the cleaner to handle partial segments without dying silently.
Source and freshness
- Source
- heroku.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.