线上canal、kafka异常处理org.apache.kafka.clients.consumer.CommitFailedException

晚上在家打LOL,突然收到线上异常邮件。还好没睡觉,赶紧处理一下。
在这里插入图片描述

1.问题

org.apache.kafka.clients.consumer.CommitFailedException:
Commit cannot be completed since the group has already rebalanced and assigned the partitions to another member. This means that the time between subsequent calls to poll() was longer than the configured max.poll.interval.ms, which typically implies that the poll loop is spending too much time message processing. You can address this either by increasing the session timeout or by reducing the maximum size of batches returned in poll() with max.poll.records.

无法完成提交,因为组已重新将分区分配给另一个成员。这意味着对poll()的后续调用之间的时间长于配置的max.poll.interval.ms,这通常意味着poll循环花费了太多时间处理消息。您可以通过增加会话
超时或使用max.poll.records减少poll()中返回的最大批大小来解决此问题。

大概的意思就是消费者创建是的参数设置有点问题。
消费时一次性poll的消息比较多,循环处理耗时较久,超过了默认的等待时长max.poll.interval.ms(默认是3000毫秒),导致触发组重新分配规则。
可以通过增加session会话时间(session.timeout.ms),或者减少每次poll(max.poll.records)数据的数量来解决问题。

2.解决方案

由于我这里用的是jar包方法,方法只提供了max.poll.records参数且默认的为100,无法设置max.poll.interval.mssession.timeout.ms。所以只能将max.poll.records参数调小一些,来保证数据处理时间降低避免问题。
在这里插入图片描述
在这里插入图片描述
如果可以自己定义消费者参数的话,可以自己设置合适的参数
在这里插入图片描述

有帮助的话,点个赞啊亲!

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值