Kafka fails to keep track of last-commited offset

旧巷老猫 提交于 2020-06-17 09:42:07

问题


Is there any known issue with kakfa-broker in managing the offsets? Bcz, problem which we are facing is when we try to restart of kafka-consumer(i.e, app restart) sometimes all the offset are reset to 0. Completely clueless on why are consumers not able to start from the last commited offset.

We are eventually facing this issue in prod wherein the whole q events are replayed again :

  • spring-boot version -- 2.2.6 release
  • spring-kafka - 2.3.7 release
  • kafka-client -2.3.1
  • apache-kafka - kafka_2.12-2.3.1

We have 10 topics with 50 partitions for each topic which belongs to same group, we increase topic-partition and consumer count at run-time based on load.

  • auto-commit = false
  • sync commit each offset after processing
  • max-poll-records is set to 1

After all this config it runs as expected in local setup, after deployed to prod we see such issues nut not at every restart. Is there any config that i'm missing. Completely Clueless!!!!!


回答1:


Do not enable auto commit per the suggestion in another answer; the listener container will more reliably commit the offsets and, as you say, you don't have the problem all the time.

Is it possible that you receive no records for a week?

Or, is it possible that your broker has a shorter offsets.retention.minutes property?

In 2.0, it was changed from a 1 day default to 1 week. If the offsets have been removed because they expired and you restart the consumer, you'll get the behavior you observe.




回答2:


You need to make sure that:

1) You are using the same Consumer Group ID

2) auto.offset.reset is set to latest

spring.kafka.consumer.group-id=your-consumer-group-id
spring.kafka.consumer.auto-offset-reset=latest

In case you are still seeing this issue, try to enable auto-commit

spring.kafka.consumer.enable-auto-commit=true

and if the issue goes away then it means that your manual commits are not working as expected.



来源:https://stackoverflow.com/questions/61913232/kafka-fails-to-keep-track-of-last-commited-offset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!