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.

exclusive_locks: clear renew-running flag before dropping isLocked (#10413)

Chris Lufe0a35762456
diff --git a/weed/wdclient/exclusive_locks/exclusive_locker.go b/weed/wdclient/exclusive_locks/exclusive_locker.go
index f7c56adb23..e45775165b 100644
--- a/weed/wdclient/exclusive_locks/exclusive_locker.go
+++ b/weed/wdclient/exclusive_locks/exclusive_locker.go
@@ -93,13 +93,15 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {
if l.renewGoroutineRunning.CompareAndSwap(false, true) {
// start a goroutine to renew the lease
go func() {
- defer l.renewGoroutineRunning.Store(false)
ctx2, cancel2 := context.WithCancel(context.Background())
defer cancel2()
for {
if err := l.renewLease(ctx2); err != nil {
glog.Warningf("Failed to renew lock %s: %v", l.lockName, err)
+ // clear the running flag before isLocked, so a RequestLock that
+ // reacquires (once isLocked is false) starts a replacement renewer
+ l.renewGoroutineRunning.Store(false)
l.isLocked.Store(false)
return
}