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 race condition on OffsetManager shutdown #658

Merged
merged 1 commit into from
May 10, 2016

Conversation

eapache
Copy link
Contributor

@eapache eapache commented May 6, 2016

If updateCommitted ran between the Unlock call and the read from clean
then we might miss the transition message and hang. Instead, use a condition
value from the sync package which does the right thing.

@wvanbergen @hasnickl fixes #656

Supersedes #657

If `updateCommitted` ran between the `Unlock` call and the read from `clean`
then we might miss the transition message and hang. Instead, use a condition
value from the `sync` package which does the right thing.
if dirty {
<-pom.clean
for pom.dirty {
pom.clean.Wait()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen sync.Cond used before. This looks like a pretty clean solution!

This seems to solve the issue with hanging, but could pom.dirty change to true after this goroutine finishes? I suppose this would only happen if MarkOffset is called after a Close, is it worth worrying about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calling anything after a Close or AsyncClose is user-error, not worth worrying about

@hasnickl
Copy link

lgtm

@eapache eapache merged commit 2acd68e into master May 10, 2016
@eapache eapache deleted the offset-manager-shutdown-take-2 branch May 10, 2016 17:56
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.

OffsetManager.Close() race condition
2 participants