0
votes

I faced very weird issue with Kafka consumer. My settings are kind of below.

<prop key="enable.auto.commit">true</prop>
<prop key="auto.commit.interval.ms">10</prop>
<prop key="auto.offset.reset">latest</prop>

There are 2 consumer in my group polling to single topic. I am not doing any manual offset management at consumer end.
Now, when my consumer was down and I had few new messages published on my topic, generally I get those messages consumed when I restarts my consumer.
But for one time I observed that after restarting my consumer, I was not able to consume those new messages(published when consumers were down and not polling) from topic. When I published few more messages, it started reading from new message offset and I lost previous message which were published when my consumer was down.
Please let me know possible cause behind this behavior.

2
auto.offset.reset isn't true/false. It is latest/earliest/none....Justin Pihony
What was your __consumer_offsets values?Justin Pihony
Hi, I am not managing offsets at consumer end.Tukaram Bhosale
No, that is the topic which is maintained by Kafka itself. It should show your commits.Justin Pihony
Unfortunately I dont have access to this topic - __consumer_offsets . I will kepp you posted.Tukaram Bhosale

2 Answers

0
votes

Consumers by default gets the messages that are published to kafka topic after the connection has been established.Try the producer and kafka console consumer without the --from-beginning parameter

0
votes

I found out the root cause finally. Default offsets.retention.minutes is set to 1440 minutes. If my consumer goes online after restart and try to find the last committed offset on broker then its not able to find it cause of above default expiry and then it starts fetching from newly arrived message offset. Increasing this retention period to 4 days helped out me.

More details here - https://cwiki.apache.org/confluence/display/KAFKA/KIP-186%3A+Increase+offsets+retention+default+to+7+days