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

x/sync: semaphore.Weighted.Acquire should try to notify other waiters when canceled #37852

Closed
zhiqiangxu opened this issue Mar 14, 2020 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@zhiqiangxu
Copy link
Contributor

zhiqiangxu commented Mar 14, 2020

When Release, if the remaining tokens are not enough for the front waiter, no waiters will be notified.

So if the canceled waiter is the front one, it should try to notify following waiters if there are remaining tokens.

I found this bug when implementing a cancelable rwmutex based on semaphore:

https://github.com/zhiqiangxu/util/blob/master/mutex/crwmutex.go

This bug can be verified by this test:

https://github.com/zhiqiangxu/util/blob/master/mutex/crwmutex_test.go#L43

I've submitted a PR here: golang/sync#10

@gopherbot gopherbot added this to the Unreleased milestone Mar 14, 2020
@zhiqiangxu zhiqiangxu changed the title x/sync: semaphore.Weighted.Acquire should try to notify other waiters x/sync: semaphore.Weighted.Acquire should try to notify other waiters when canceled Mar 14, 2020
@cagedmantis cagedmantis added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 20, 2020
@cagedmantis
Copy link
Contributor

This has been fixed via: https://go-review.googlesource.com/c/sync/+/223418

@golang golang locked and limited conversation to collaborators Mar 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants