Reputation: 11
Playing around with Apache Kafka and its retention mechanism I'm thinking about following situation:
As you can see the consumer lost the offsets 6-10.
Question, is such a situation possible at all? With other words, will the cleaner execute while there is an active consumer? If yes, is the consumer able to somehow recognize that gap?
Upvotes: 0
Views: 799
Reputation: 196
Upvotes: 0
Reputation: 26950
Yes such a scenario can happen. The exact steps will be a bit different:
auto.offset.reset
to find a new valid offset.
latest
, the consumer moves to the end of the partitionearliest
the consumer moves to offset 11none
or unset, the consumer throws an exceptionTo avoid such scenarios, you should monitor the lead of your consumer group. It's similar to the lag, but the lead indicates how far from the start of the partition the consumer is. Being near the start has the risk of messages being deleted before they are consumed.
If consumers are near the limits, you can dynamically add more consumers or increase the topic retention size/time if needed.
Setting auto.offset.reset
to none
will throw an exception if this happens, the other values only log it.
Upvotes: 1