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>
This commit is contained in:
@@ -70,7 +70,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
println("lock:", err.Error())
|
glog.V(2).Infof("Failed to acquire lock %s: %v", l.lockName, err)
|
||||||
time.Sleep(InitLockInterval)
|
time.Sleep(InitLockInterval)
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
@@ -79,6 +79,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {
|
|||||||
|
|
||||||
l.isLocked.Store(true)
|
l.isLocked.Store(true)
|
||||||
l.clientName = clientName
|
l.clientName = clientName
|
||||||
|
glog.V(1).Infof("Acquired lock %s", l.lockName)
|
||||||
|
|
||||||
// Each lock has and only has one goroutine
|
// Each lock has and only has one goroutine
|
||||||
if l.renewGoroutineRunning.CompareAndSwap(false, true) {
|
if l.renewGoroutineRunning.CompareAndSwap(false, true) {
|
||||||
@@ -100,11 +101,11 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
atomic.StoreInt64(&l.token, resp.Token)
|
atomic.StoreInt64(&l.token, resp.Token)
|
||||||
atomic.StoreInt64(&l.lockTsNs, resp.LockTsNs)
|
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
|
return err
|
||||||
}); err != nil {
|
}); 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)
|
l.isLocked.Store(false)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user