You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We recently encountered a deadlock with the library. After some digging, we found out that it tries to acquire the read lock in getClosetN, and then in GetPartitionOwner.
func (c*Consistent) GetPartitionOwner(partIDint) Member {
c.mu.RLock()
deferc.mu.RUnlock()
It's not safe to call RLock and RUnlock twice in one goroutine while having another goroutine call Lock simultaneously. The discussion here and here explain it better than me. In addition, to quote from the RWMutex documentation:
If a goroutine holds a RWMutex for reading and another goroutine might call Lock, no goroutine should expect to be able to acquire a read lock until the initial read lock is released. In particular, this prohibits recursive read locking.
The probability is low since it requires a Lock happens immediately after the first RLock, but it would happen when you have a large amount of reads/writes and run for a sufficiently long time.
The text was updated successfully, but these errors were encountered:
We recently encountered a deadlock with the library. After some digging, we found out that it tries to acquire the read lock in
getClosetN
, and then inGetPartitionOwner
.consistent/consistent.go
Lines 302 to 312 in f0660af
consistent/consistent.go
Lines 284 to 287 in f0660af
It's not safe to call RLock and RUnlock twice in one goroutine while having another goroutine call Lock simultaneously. The discussion here and here explain it better than me. In addition, to quote from the RWMutex documentation:
You can also go to this Go playground and replicate it yourself: https://go.dev/play/p/pEhnPbsnDG
The probability is low since it requires a
Lock
happens immediately after the firstRLock
, but it would happen when you have a large amount of reads/writes and run for a sufficiently long time.The text was updated successfully, but these errors were encountered: