Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shutdown and race-condition in consumer-group example #1404

Merged
merged 2 commits into from
Jun 21, 2019

Conversation

skidder
Copy link
Contributor

@skidder skidder commented Jun 19, 2019

The Kafka consumer groups example has two issues:

  1. A race condition causes the ready channel to be reassigned before the consumer starts, leading to the main go-routine reading from a different ready channel than the one that is closed in the consumer Setup function.
  2. The consumer go-routine doesn't exit cleanly when a termination signal is sent. But the termination signal handling wasn't configured because of the aforementioned race condition, so this wouldn't have worked regardless.

This PR fixes both problems by reassigning the ready channel variable only after a rebalance, and by using a cancellable context and waitgroup to ensure that the Kafka client is closed cleanly upon receiving a termination signal.

@ghost ghost added the cla-needed label Jun 19, 2019
@ghost ghost removed the cla-needed label Jun 19, 2019
@bai
Copy link
Contributor

bai commented Jun 21, 2019

Many thanks!

@bai bai merged commit 4154a59 into IBM:master Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants