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

Prevent race condition caused by WaitGroup re-use #9335

Merged
merged 2 commits into from
Jan 29, 2018
Merged

Conversation

joelegasse
Copy link
Contributor

This has been an elusive issue, but this should fix the data race seen occasionally during testing.

  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

@joelegasse joelegasse requested a review from jwilder January 17, 2018 18:10
@ghost ghost assigned joelegasse Jan 17, 2018
@ghost ghost added the review label Jan 17, 2018
Copy link
Contributor

@mark-rushakoff mark-rushakoff left a comment

Choose a reason for hiding this comment

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

LGTM. I don't have a reliable repro case for this, but if the panic still occurs, we'll find out.

wg sync.WaitGroup // waitgroup for active level compaction goroutines
done chan struct{} // channel to signal level compactions to stop
levelWorkers int // Number of "workers" that expect compactions to be in a disabled state
wg *sync.WaitGroup // waitgroup for active level compaction goroutines
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to read the code pretty closely to understand why wg is kept as a field even though it's passed through some methods as arguments. The comment here or in enableLevelCompactions could probably explain it better.

Copy link
Contributor

@jwilder jwilder left a comment

Choose a reason for hiding this comment

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

Hopefully this does the trick.

Copy link
Contributor

@e-dard e-dard left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@joelegasse joelegasse merged commit 9f75729 into master Jan 29, 2018
@ghost ghost removed the review label Jan 29, 2018
@joelegasse joelegasse deleted the jl-race branch January 29, 2018 21:30
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.

4 participants