-
Notifications
You must be signed in to change notification settings - Fork 190
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
fix: rueidislock deadlock caused by the absence of peers #458
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
@@ -234,10 +232,6 @@ func (m *locker) onInvalidations(messages []rueidis.RedisMessage) { | |||
if messages == nil { | |||
m.mu.RLock() | |||
for _, g := range m.gates { | |||
select { | |||
case g.ch <- struct{}{}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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{}{}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notify one peer if any without blocking.
fixes #457
There is a rare chance that when receiving
bulking invalidation
and all peers are aborted, the following linerueidis/rueidislock/lock.go
Line 324 in 33e9233
This PR removes the unnecessary notification to the
g.ch
from thebulking invalidation
and makes the mutex never be blocked.