Browse Source

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 <anton@devops>
codex/8712-directory-marker-content-type
Anton 2 days ago
committed by GitHub
parent
commit
8e7b15a995
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 7
      weed/wdclient/exclusive_locks/exclusive_locker.go

7
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 {

Loading…
Cancel
Save