Skip to content

Conversation

@zhiqiangxu
Copy link
Contributor

@zhiqiangxu 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

@gopherbot
Copy link
Contributor

This PR (HEAD: 7081629) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/sync/+/223418 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@zhiqiangxu zhiqiangxu changed the title the front waiter should try to notify waiters the front waiter should try to notify other waiters when cancel Mar 14, 2020
@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
Within the next week or so, a maintainer will review your change and provide
feedback. See https://golang.org/doc/contribute.html#review for more info and
tips to get your patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11, it means that this CL will be reviewed as part of the next development
cycle. See https://golang.org/s/release for more details.


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 3:

A change like this should include a test. Thanks.


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: ee312a9) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/sync/+/223418 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from 志强 徐:

Patch Set 3:

Patch Set 3:

A change like this should include a test. Thanks.

I've uploaded a test, basically translating https://github.com/zhiqiangxu/util/blob/master/mutex/crwmutex_test.go#L43


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 903461d) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/sync/+/223418 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

This PR (HEAD: 529f392) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/sync/+/223418 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Ian Lance Taylor:

Patch Set 6: Run-TryBot+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 6:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=def2cc73


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 6: TryBot-Result+1

TryBots are happy.


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan C. Mills:

Patch Set 6:

(3 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan C. Mills:

Patch Set 6:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: 29b6ff2) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/sync/+/223418 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from 志强 徐:

Patch Set 6:

(4 comments)

I've updated with a new test 😊


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan C. Mills:

Patch Set 7: Run-TryBot+1 Code-Review+2

(3 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 7:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=14b8354a


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 7: TryBot-Result+1

TryBots are happy.


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from 志强 徐:

Patch Set 7:

(2 comments)

Updated, btw, about the test runner duration, does this mean the Test won't fail until 10min?


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan C. Mills:

Patch Set 7:

Patch Set 7:

(2 comments)

Updated, btw, about the test runner duration, does this mean the Test won't fail until 10min?

That's correct. But since it should never fail at all, that shouldn't be a problem. 😅


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan C. Mills:

Patch Set 7:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@zhiqiangxu zhiqiangxu changed the title the front waiter should try to notify other waiters when cancel semaphore: unblock waiters when the front waiter cancels Mar 17, 2020
@gopherbot
Copy link
Contributor

Message from 志强 徐:

Patch Set 7:

(1 comment)

Patch Set 7:

Patch Set 7:

(2 comments)

Updated, btw, about the test runner duration, does this mean the Test won't fail until 10min?

That's correct. But since it should never fail at all, that shouldn't be a problem. 😅

I'm ok with that then~


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Bryan C. Mills:

Patch Set 8: Run-TryBot+1

Thanks! Will submit after another TryBot pass.


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 8:

TryBots beginning. Status page: https://farmer.golang.org/try?commit=b4c2eb2a


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

gopherbot pushed a commit that referenced this pull request Mar 17, 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 Change-Id: Id8564976bd375a82c4fbc6cb08b0bb83118a346c GitHub-Last-Rev: 29b6ff2 GitHub-Pull-Request: #10 Reviewed-on: https://go-review.googlesource.com/c/sync/+/223418 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 8: TryBot-Result+1

TryBots are happy.


Please don’t reply on this GitHub thread. Visit golang.org/cl/223418.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR is being closed because golang.org/cl/223418 has been merged.

@gopherbot gopherbot closed this Mar 17, 2020
sherifabdlnaby pushed a commit to sherifabdlnaby/sync that referenced this pull request Feb 24, 2021
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 Change-Id: Id8564976bd375a82c4fbc6cb08b0bb83118a346c GitHub-Last-Rev: 29b6ff2 GitHub-Pull-Request: golang#10 Reviewed-on: https://go-review.googlesource.com/c/sync/+/223418 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
anatoliinzrnk added a commit to anatoliinzrnk/go-sync that referenced this pull request Sep 25, 2024
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 Change-Id: Id8564976bd375a82c4fbc6cb08b0bb83118a346c GitHub-Last-Rev: 29b6ff26bf779d23239cfe64a395378a9e41d1fc GitHub-Pull-Request: golang/sync#10 Reviewed-on: https://go-review.googlesource.com/c/sync/+/223418 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants