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

Dispatch: Make sure mutex gets unlocked on call to Stop #2558

Merged
merged 2 commits into from
Apr 27, 2021
Merged

Dispatch: Make sure mutex gets unlocked on call to Stop #2558

merged 2 commits into from
Apr 27, 2021

Conversation

aknuds1
Copy link
Contributor

@aknuds1 aknuds1 commented Apr 27, 2021

It looks as if Dispatch.Stop doesn't unlock the mutex if d.cancel == nil. I'm rectifying it to unlock it also if d.cancel == nil and the method returns early. It seems to fix a deadlock in Grafana (on server shutdown), during our test suite.

Here's a stacktrace of the involved goroutines when the deadlock occurs.

Let me know if you want me to write a test also.

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

LGTM.

@stevesg
Copy link
Contributor

stevesg commented Apr 27, 2021

LGTM

Copy link
Member

@gotjosh gotjosh left a comment

Choose a reason for hiding this comment

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

LGTM

@beorn7
Copy link
Member

beorn7 commented Apr 27, 2021

Interestingly, the unlock was correctly suggested in the review for the PR that introduced the bug, but then somehow slipped under the radar.

@beorn7 beorn7 merged commit 88f32c5 into prometheus:master Apr 27, 2021
@beorn7 beorn7 deleted the bugfix/unlock-mutex branch April 27, 2021 20:40
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.

6 participants