Use case
I wrote a prometheus exporter for Kafka Consumer Group offsets (https://github.com/cloudworkz/kafka-minion) which works by consuming the internal __consumer_offsets
topic. Key and value for all messages inside of this topic are binary and I am able to decode them. When any group offsets expire Kafka is supposed to create a tombstone for this key (which consists of group id, topic name and partition id).
The problem
This approach works very well so far, however Kafka apparently does not produce a tombstone for some expired offsets / groups sometimes. I consumed the offsets topic with this command:
kafka-console-consumer.sh --from-beginning --topic __consumer_offsets zookeeper.connect=${ZOO_HOST} --bootstrap-server="${KAFKA_HOST}" --formatter "kafka.coordinator.group.GroupMetadataManager\$OffsetsMessageFormatter
This produces formatted log lines which contain the offset commits along with their group names, partitionID and commit timestamp. It will also print the tombstones (NULL value). There are some consumer group offsets which still have no tombstones yet, even though their offsets have been commited 6 months ago (offset retention is set to 2w). When I list consumer groups from Kafka (using the other shell scripts), Kafka does not list this consumer group either - so internally Kafka is apparently aware that these offsets are expired.
The question
Why does Kafka sometimes does not produce tombstones for expired offsets? How does Kafka know these offsets are expired when it apparently does not rely on receiving Tombstones for expired group offsets?