skroutz / rafka

Kafka proxy with a simple API, speaking the Redis protocol
https://engineering.skroutz.gr/blog/kafka-rails-integration/
GNU General Public License v3.0
8 stars 0 forks source link

cons: Don't execute Poll & shutdown concurrently #77

Closed agis closed 5 years ago

agis commented 5 years ago

In librdkafka/confluent-kafka-go we shouldn't call Poll() concurrently with Close() or Unsubscribe(), since that might lead to race conditions. We noticed such an issue when upgrading to librdkafka 0.11.6 and 1.0.0, where consumers would block in Poll() forever if rafka attempted to shutdown right in the middle of a call to Poll() (i.e. clients calling BLPOP). See edenhill/librdkafka#2333 for background.

This patch synchronizes access between a consumer's Poll() and its shutdown sequence, so that the two may never run concurrently. Furthermore, if a consumer is terminated then calling Poll() will immediately return nil without communicating with Kafka at all.

Fixes consumers blocking on Poll() when the server is shutting down, with librdkafka 0.11.6 and 1.0.0.

avgerin0s commented 5 years ago

Good job @agis

konstantinoskostis commented 5 years ago

Nice @agis! Great job!