panic: interface conversion: interface {} is nil, not chan *sarama.ProducerError

7 篇文章 0 订阅
7 篇文章 0 订阅

使用golang kafka sarama 包时,遇到如下问题:
高并发情况下使用同步sync producer,偶尔遇到crash:

panic: interface conversion: interface {} is nil, not chan *sarama.ProducerError

goroutine 413 [running]:
github.com/Shopify/sarama.(*syncProducer).handleSuccesses(0xc420384840)
/home/lanyang/github.com/Shopify/sarama/sync_producer.go:147 +0x139
github.com/Shopify/sarama.handleSuccesses)-fm()
/home/lanyang/src/github.com/Shopify/sarama/sync_producer.go:76 +0x2f
github.com/Shopify/sarama.withRecover(0xc4201d0750)
/home/lanyang/src/github.com/Shopify/sarama/utils.go:43 +0x45
created by github.com/Shopify/sarama.newSyncProducerFromAsyncProducer
/home/lanyang/src/github.com/Shopify/sarama/sync_producer.go:76 +0x112

问题不容易复现,github上已经留言:
https://github.com/Shopify/sarama/issues/785

download
https://github.com/Shopify/sarama
https://shopify.github.io/sarama/

doc
https://godoc.org/github.com/Shopify/sarama

依赖

github.com/davecgh/go-spew

github.com/eapache/go-resiliency
github.com/eapache/go-xerial-snappy
github.com/eapache/queue

github.com/pierrec/lz4
github.com/pierrec/xxHash

github.com/rcrowley/go-metrics

github.com/golang/snappy

如果kafka down掉,又恢复,client 可自动连接上。
异步方式,网络断开后,仍然会从queue,放入producer的channel中,重连后,这些内容丢失。

例子参考

sync
http://legendtkl.com/2016/06/30/kafka-in-action/
https://studygolang.com/articles/7102

async
https://studygolang.com/articles/11199

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值