简体   繁体   English

卡夫卡消费群抵消降至-1

[英]Kafka consumer group offset goes down to -1

We run a Kafka cluster in Kubernetes based on the gcr.io/google_containers/kubernetes-kafka:1.0-10.2.1 docker image with the zookeeper backend using gcr.io/google_containers/kubernetes-zookeeper:1.0-3.4.10 with three instances of both kafka and zookeeper. 我们基于gcr.io/google_containers/kubernetes-kafka:1.0-10.2.1镜像在Kubernetes中运行一个Kafka集群,并使用gcr.io/google_containers/kubernetes-zookeeper:1.0-3.4.10后端使用gcr.io/google_containers/kubernetes-zookeeper:1.0-3.4.10和三个实例卡夫卡和动物园管理员

We have a few different consumer groups that both consume and produces data on three different topics. 我们有一些不同的消费群体,它们同时消费和产生有关三个不同主题的数据。

Behaviour: Sometimes a consumer group will set their offset for a topic on a partition to -1 and from then on stop consuming on that topic all together. 行为:有时,某个消费者组会将某个分区上某个主题的偏移量设置为-1,然后从此开始停止对该主题的所有消耗。 If we restart our consumers we might see them setting their offset to the latest offset, which might mean that the consumer has missed messages in the time between it going to -1 and being restarted. 如果重新启动使用者,我们可能会看到他们将偏移量设置为最新的偏移量,这可能意味着使用者在从-1到重新启动之间的时间里错过了消息。

I'm having issues finding why a consumer group would ever set its offset to -1 and why it would do so "randomly" after days of uptime. 我遇到了一个问题,那就是为什么一个消费群体为什么要将其偏移量设置为-1,以及为什么它会在几天的正常运行时间后“随机地”设置为-1。 Is there any logical explanation to why Kafka would set this offset for a certain consumer? 对于Kafka为什么会为特定消费者设置此偏移量,是否有任何逻辑上的解释? Cannot see anything in our actual consumers that indicates that they explicitly are doing this. 在我们的实际消费者中看不到任何表明他们明确在这样做的东西。

We are currently having consumers both running in golang and in Node.js , where all are facing this issue, so our current assumption is that this issue does not have to do with our consumers, but rather with our Kafka setup. 当前,我们正在使消费者都在golangNode.js运行,所有这些都面临此问题,因此我们目前的假设是,此问题与我们的消费者无关,而与我们的Kafka设置有关。

The default offset retention policy offsets.retention.minutes used to be 1 day and in older Kafka versions the offset got wiped out even for active consumers. 默认的偏移量保留策略offsets.retention.minutes过去是1天,而在较旧的Kafka版本中,即使对于活跃的消费者,偏移量也会被清除掉。 Fixed with KIP-211 KIP-211固定

We originally discovered this with Kafka 0.10.2.1, a few select topics lost the consumer group offsets (ie, turned to -1) because no messages arrived on the topic for a couple of days and the offset retention policy kicked in and wiped out offsets for active consumers. 我们最初是在Kafka 0.10.2.1中发现的,一些选择的主题丢失了消费者组偏移(即变为-1),因为几天来没有任何消息到达该主题,并且偏移保留策略开始生效并消除了偏移对于活跃的消费者。

We were able to workaround this by increasing the retention setting to 7 days which seems to be what Kafka also ended up doing, see KIP-186 我们可以通过将保留时间设置增加到7天来解决此问题,这似乎是卡夫卡最终要做的事情,请参见KIP-186

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM