-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Race condition in dispatcher code #2182
Labels
Comments
You're right about the race. As for the fix, it might even be possible to avoid locking by moving some initialization happening in |
@jtlisi still interested to tackle this one? |
Sure! However, I'm not sure how to fix this without locking. I do have a way to fix with this with locking if that's acceptable. |
gotjosh
added a commit
to gotjosh/cortex
that referenced
this issue
Aug 24, 2020
Signed-off-by: gotjosh <josue@grafana.com>
gouthamve
pushed a commit
to cortexproject/cortex
that referenced
this issue
Aug 24, 2020
#3065) * Remove TODO about prometheus/alertmanager#2182 as it got merged Signed-off-by: gotjosh <josue@grafana.com> * Remove TODO about prometheus/alertmanager#2200 as it got merged Signed-off-by: gotjosh <josue@grafana.com> * Register the Alertmanager API metrics Signed-off-by: gotjosh <josue@grafana.com> * Add a changelog entry Signed-off-by: gotjosh <josue@grafana.com> * Fix tests Signed-off-by: gotjosh <josue@grafana.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I noticed a mild race condition in the dispatch package.
I wrote a small test in the
dispatch
package to demonstrate a race condition in the dispatch code:Test Added to `dispatch/dispatch_test.go:
Test Output:
Although it will not happen as things stand, in theory simultaneous call to
Stop()
andRun()
will cause a panic. The fix is simple. The operations on the cancel field in theStop
andRun
functions require a lock.Let me know if I'm mistaken. Otherwise, I can open a small PR with the fix.
The text was updated successfully, but these errors were encountered: