From 8e7b15a99529c842a89a329c308d865b4c73ffd5 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 21 Mar 2026 22:36:26 +0200 Subject: [PATCH] wdclient/exclusive_locks: replace println with glog in ExclusiveLocker (#8723) RequestLock used a bare println to report transient lock acquisition failures ('lock: already locked by ...'), which writes directly to stdout instead of going through the structured logging pipeline. This causes log noise at the wrong level and cannot be filtered with -v or redirected like glog output. Changes: - println("lock:", ...) -> glog.V(2).Infof for per-retry acquisition errors (transient, high-frequency during startup when another instance still holds) - Add glog.V(1).Infof when the lock is successfully acquired - Add glog.V(2).Infof for successful renewals (replaces commented-out println) - Errorf -> Warningf for renewal failures (the goroutine exits cleanly, it is not a fatal error; the caller will re-acquire via RequestLock) Co-authored-by: Anton Ustyugov --- weed/wdclient/exclusive_locks/exclusive_locker.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/weed/wdclient/exclusive_locks/exclusive_locker.go b/weed/wdclient/exclusive_locks/exclusive_locker.go index 175718cd2..e61774ae8 100644 --- a/weed/wdclient/exclusive_locks/exclusive_locker.go +++ b/weed/wdclient/exclusive_locks/exclusive_locker.go @@ -70,7 +70,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) { } return err }); err != nil { - println("lock:", err.Error()) + glog.V(2).Infof("Failed to acquire lock %s: %v", l.lockName, err) time.Sleep(InitLockInterval) } else { break @@ -79,6 +79,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) { l.isLocked.Store(true) l.clientName = clientName + glog.V(1).Infof("Acquired lock %s", l.lockName) // Each lock has and only has one goroutine if l.renewGoroutineRunning.CompareAndSwap(false, true) { @@ -100,11 +101,11 @@ func (l *ExclusiveLocker) RequestLock(clientName string) { if err == nil { atomic.StoreInt64(&l.token, resp.Token) atomic.StoreInt64(&l.lockTsNs, resp.LockTsNs) - // println("ts", l.lockTsNs, "token", l.token) + glog.V(2).Infof("Renewed lock %s: ts %d token %d", l.lockName, l.lockTsNs, l.token) } return err }); err != nil { - glog.Errorf("failed to renew lock: %v", err) + glog.Warningf("Failed to renew lock %s: %v", l.lockName, err) l.isLocked.Store(false) return } else {