-
Notifications
You must be signed in to change notification settings - Fork 18k
x/sync/singleflight: panic in Do fn results in deadlock #33519
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
Comments
|
The simplest workaround is to defer a recover inside the callback function that assigns it's value to a variable in the outer scope, like this: https://play.golang.org/p/YjaqG4vhDMR Hope this is of any huse to you. |
Yeah, that's what I did but I would or document that this is needed or let singleflight also handle panics hence this issue. |
singleflight might have chosen to not defer recover because of defer performance has historically been pretty noticable and groupcache (where singleflight originates) definitely strived to be fast. |
At first sight the implementation in groupcache seems to have the same problem |
Since go1.14 add inlined defer support, will this be fixed to avoid dead lock? |
/cc @rsc @ianlancetaylor @dvyukov @aclements per owners. |
Change https://golang.org/cl/251677 mentions this issue: |
Fixed by CL 251677. |
Change https://golang.org/cl/260717 mentions this issue: |
The js port does not yet support os/exec. Updates golang/go#37100 Updates golang/go#33519 Change-Id: I9608b7febfdc274dc1b9f34a92d00ef7bea4e13c Reviewed-on: https://go-review.googlesource.com/c/sync/+/260717 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
The js port does not yet support os/exec. Updates golang/go#37100 Updates golang/go#33519 Change-Id: I9608b7febfdc274dc1b9f34a92d00ef7bea4e13c Reviewed-on: https://go-review.googlesource.com/c/sync/+/260717 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
This is the newest stable version
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
The fn given to the singleflight group.Do panicked and was recovered outside the group.Do.
https://play.golang.org/p/s7UKLR6JqRt
What did you expect to see?
The call would be discarded and the lock released.(Maybe the panic would be passed to all waiting calls with the same key)
What did you see instead?
The call panicked but the lock was never released resulting in a deadlock of all following calls with the same key.
The text was updated successfully, but these errors were encountered: