correct lock accounting

possibly fix https://github.com/seaweedfs/seaweedfs/issues/5082
This commit is contained in:
chrislu 2023-12-22 14:16:23 -08:00
parent c4badf7396
commit 03c4b2e988

View file

@ -132,6 +132,12 @@ func (lt *LockTable[T]) ReleaseLock(key T, lock *ActiveLock) {
} }
} }
if lock.lockType == ExclusiveLock {
entry.activeExclusiveLockOwnerCount--
} else {
entry.activeSharedLockOwnerCount--
}
// If there are no waiters, release the lock // If there are no waiters, release the lock
if len(entry.waiters) == 0 && entry.activeExclusiveLockOwnerCount <= 0 && entry.activeSharedLockOwnerCount <= 0 { if len(entry.waiters) == 0 && entry.activeExclusiveLockOwnerCount <= 0 && entry.activeSharedLockOwnerCount <= 0 {
delete(lt.locks, key) delete(lt.locks, key)
@ -146,11 +152,6 @@ func (lt *LockTable[T]) ReleaseLock(key T, lock *ActiveLock) {
fmt.Printf("\n") fmt.Printf("\n")
} }
} }
if lock.lockType == ExclusiveLock {
entry.activeExclusiveLockOwnerCount--
} else {
entry.activeSharedLockOwnerCount--
}
// Notify the next waiter // Notify the next waiter
entry.cond.Broadcast() entry.cond.Broadcast()