Fix deadlock in Lock.Stale

With debug logging enabled this method would take a lock and then
format the lock as a string. Since PR #4022 landed the string
formatting method has also taken the lock, so this deadlocks.

Instead just record the lock ID, as is done elsewhere.
This commit is contained in:
Fergus Dall 2023-01-27 03:08:21 +11:00
parent 65923e9c26
commit 04da31af2b
1 changed files with 1 additions and 1 deletions

View File

@ -222,7 +222,7 @@ var StaleLockTimeout = 30 * time.Minute
func (l *Lock) Stale() bool {
l.lock.Lock()
defer l.lock.Unlock()
debug.Log("testing if lock %v for process %d is stale", l, l.PID)
debug.Log("testing if lock %v for process %d is stale", l.lockID, l.PID)
if time.Since(l.Time) > StaleLockTimeout {
debug.Log("lock is stale, timestamp is too old: %v\n", l.Time)
return true