-
Notifications
You must be signed in to change notification settings - Fork 803
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 when stopping chunks memcached client #4511
Conversation
We need to check again if we have been asked to quit before writing to the results chan. Also, the reader of that chan should not close it, because this can trigger a panic in a writer. The chan will be cleaned up by garbage- collection once all the readers and writers have exited on quit. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
pkg/chunk/cache/memcached.go
Outdated
case <-c.quit: | ||
return | ||
default: | ||
input.resultCh <- res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sending on the channel inside the default case seems that it could still block if it enters the default clause just before quit is closed.
Can we make it a case instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bboreham ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry was on vacation. Very good point; done.
Don't open another race where quit is closed just after we check it. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
LGTM |
* Fix race when stopping chunks memcached client We need to check again if we have been asked to quit before writing to the results chan. Also, the reader of that chan should not close it, because this can trigger a panic in a writer. The chan will be cleaned up by garbage- collection once all the readers and writers have exited on quit. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * simplify select Don't open another race where quit is closed just after we check it. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> Signed-off-by: Manish Kumar Gupta <manishkg@microsoft.com>
* Fix race when stopping chunks memcached client We need to check again if we have been asked to quit before writing to the results chan. Also, the reader of that chan should not close it, because this can trigger a panic in a writer. The chan will be cleaned up by garbage- collection once all the readers and writers have exited on quit. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> * simplify select Don't open another race where quit is closed just after we check it. Signed-off-by: Bryan Boreham <bjboreham@gmail.com> Signed-off-by: Alvin Lin <alvinlin@amazon.com>
We need to check again if we have been asked to quit before writing to the results chan.
Also, the reader of that chan should not close it, because this can trigger a panic in a writer. The chan will be cleaned up by garbage-collection once all the readers and writers have exited on quit.
Which issue(s) this PR fixes:
Fixes #4508
Checklist
CHANGELOG.md
updated