fix: rueidislock deadlock caused by the absence of peers#458
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #458 +/- ##
=======================================
Coverage 95.98% 95.99%
=======================================
Files 67 67
Lines 31543 31528 -15
=======================================
- Hits 30276 30264 -12
+ Misses 1085 1083 -2
+ Partials 182 181 -1 ☔ View full report in Codecov by Sentry. |
12ac70a to
dd517c1
Compare
dd517c1 to
627192e
Compare
rueian
commented
Jan 27, 2024
| m.mu.RLock() | ||
| for _, g := range m.gates { | ||
| select { | ||
| case g.ch <- struct{}{}: |
Collaborator
Author
There was a problem hiding this comment.
This may cause the below g.ch <- struct{}{} below stuck.
| for i := int32(0); i < m.totalcnt; i++ { | ||
| cases = append(cases, reflect.SelectCase{Dir: reflect.SelectRecv, Chan: reflect.ValueOf(g.csc[i])}) | ||
| } | ||
| reflect.Select(cases) |
Collaborator
Author
There was a problem hiding this comment.
This is no longer needed because we already clear each of theg.csc channel before entering the monitoring function.
| g.ch <- struct{}{} | ||
| } else if m.gates != nil { | ||
| select { | ||
| case g.ch <- struct{}{}: |
Collaborator
Author
There was a problem hiding this comment.
Notify one peer if any without blocking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes #457
There is a rare chance that when receiving
bulking invalidationand all peers are aborted, the following linerueidis/rueidislock/lock.go
Line 324 in 33e9233
This PR removes the unnecessary notification to the
g.chfrom thebulking invalidationand makes the mutex never be blocked.