Compaction retains the latest value for each key within a partition. It is useful for a change log that rebuilds current state, such as inventory by item. It does not mean every older record disappears immediately, and it does not renumber the offsets that survive. A consumer must tolerate gaps. Records without keys do not provide a key identity for this cleanup. These tasks use two updates for one key and an unrelated key that must stay. Change the cleanup policy, run the local cleaner and inspect both retained values and offsets. The model performs a deterministic cleanup pass; real Kafka cleans segments in the background and can retain additional recent records.
Inspect the topics, partition logs and group offsets before changing the cluster.