Bugfix: conditional variable broadcast channel size #3906
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changed?
Why?
0 size channel does not guarantee ordering
when the conditional is initialized, the signal channel is correctly initialized with size 1
however (the bug) incorrectly re-initialized the signal channel with size 0
when a coroutine waits for notification, there is a time gap & lock gap between accessing the signal channel and selecting on the signal channel
so signal delivered during the above gap can be dropped
How did you test it?
Loop go test -race && UT
Potential risks
No risk
Is hotfix candidate?
No, broadcast function implemented but not used in production logic