When a client produces a new event with an existing key, the old value is overwritten with the new value in the compacted log segment.
B.
When a client produces a new event with an existing key, the broker immediately deletes the offset of the existing event.
C.
Topic compaction does not remove old events; instead, when clients consume events from a compacted topic, they store events in a hashmap that maintains the latest value.
D.
Compaction will keep exactly one message per key after compaction of inactive log segments.
The Answer Is:
D
This question includes an explanation.
Explanation:
Log compactionensures that Kafka retains at least thelatest value per keyin a topic. Compaction happensin the backgroundand removes older records with the same keyin inactive log segments, not immediately.
From theKafka Documentation > Log Compaction:
“Kafka guarantees that thelast message for each keywill be retained in the log after compaction, even if earlier messages with the same key are deleted.”
So, D is correct. A is incorrect because compaction does not overwrite; it's a background process. B is incorrect—deletion is not immediate. C incorrectly suggests client-side hashmap behavior.