Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

correct lock accounting

chrislu03c4b2e98807
diff --git a/weed/util/lock_table.go b/weed/util/lock_table.go
index bf3da7c37f..efc4114e7e 100644
--- a/weed/util/lock_table.go
+++ b/weed/util/lock_table.go
@@ -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 len(entry.waiters) == 0 && entry.activeExclusiveLockOwnerCount <= 0 && entry.activeSharedLockOwnerCount <= 0 {
delete(lt.locks, key)
@@ -146,11 +152,6 @@ func (lt *LockTable[T]) ReleaseLock(key T, lock *ActiveLock) {
fmt.Printf("\n")
}
}
- if lock.lockType == ExclusiveLock {
- entry.activeExclusiveLockOwnerCount--
- } else {
- entry.activeSharedLockOwnerCount--
- }
// Notify the next waiter
entry.cond.Broadcast()