kafka0.9 Commit cannot be completed due to group rebalance

1,在使用kafka0.9新的客户端消费消息时,会出现
org.apache.kafka.clients.consumer.CommitFailedException:Commit cannot be completed due to group rebalance。
的问题,出现的原因就是consumer在一定时间内没有发送心跳给coordinator(kafka 0.9后新出现的角色)。

问题链接

参数优化说明

Kafka triggers a rebalance if it doesn't receive at least one heartbeat within session time out. If the rebalance is triggered, the commit will fail. That is expected. So the question is why has the heartbeat not happened? There might be a couple of reasons for that.
First thing is that you are doing a manual commit. Starting 0.9, heartbeat doesn't happen in a separate thread. The consumer runs on a single thread which handles commit, heartbeat and polling. So the heartbeat happens when you do a consumer.poll() or consumer.commit(). So if your processing time is exceeding the session time out, that might cause the heartbeat to fail.

There is a known issue in kafka 0.9 consumer which might cause the problem you are facing.

https://issues.apache.org/jira/browse/KAFKA-3627
In either case, downgrading your consumer to 0.8 will solve the problem.
Edit: You can try increasing the session time out to as high as 5 min and see if it works.
Regarding kafka configs
Kafka server expects that it receives at least one heartbeat within the session time out. So the consumer tries to do a heartbeat at most (session time out/heartbeat times). Some heartbeats might be missed. So your heartbeat time should not be more than 1/3 of the session time out. (You can refer to the docs)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,951评论 0 23
  • =========================================================...
    lavor阅读 3,508评论 0 5
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,997评论 19 139
  • 董艺一摸到饿下去的口袋,心里就突然发慌起来。 董艺自小,就有一个梦想,就是拥有自己的第一套碧旭牌蓝牙耳机。要说为什...
    点壹阅读 499评论 0 3
  • 我想我应该比正常人有资格谈论这件事情,因为我又一次从急救室出来。 如果死亡带走了我,我想我可以安然离去。但我最不想...
    沐格小姐阅读 295评论 0 0