Skip to content

Commit

Permalink
Merge pull request portworx#124 from portworx/PWX-33266
Browse files Browse the repository at this point in the history
PWX-33266: Added lock duration to timeout log
  • Loading branch information
Pure-AdamuKaapan authored Feb 15, 2024
2 parents c3adade + 68fe73c commit 18d4792
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bolt/kv_bolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ func (kv *boltKV) LockWithTimeout(
select {
case <-timeout:
logrus.Warnf("XXX LOCK timeout on %v after %v", key, lockHoldDuration)
kv.LockTimedout(key)
kv.LockTimedout(key, lockHoldDuration)
case <-lockChan:
logrus.Warnf("XXX LOCK chan wakeup on %v", key)
return
Expand Down
10 changes: 5 additions & 5 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (b *BaseKvdb) CheckLockTimeout(
b.lock.Lock()
defer b.lock.Unlock()
if lockTimeout > 0 && time.Since(startTime) > lockTimeout {
b.lockTimedout(key)
b.lockTimedout(key, lockTimeout)
}
}

Expand All @@ -101,15 +101,15 @@ func (b *BaseKvdb) GetLockHoldDuration() time.Duration {
}

// LockTimedout does lock timedout.
func (b *BaseKvdb) LockTimedout(key string) {
func (b *BaseKvdb) LockTimedout(key string, timedOutAfter time.Duration) {
b.lock.Lock()
defer b.lock.Unlock()
b.lockTimedout(key)
b.lockTimedout(key, timedOutAfter)
}

// lockTimedout function is invoked if lock is held past configured timeout.
func (b *BaseKvdb) lockTimedout(key string) {
b.FatalCb(kvdb.ErrLockHoldTimeoutTriggered, "Lock %s hold timeout triggered", key)
func (b *BaseKvdb) lockTimedout(key string, timedOutAfter time.Duration) {
b.FatalCb(kvdb.ErrLockHoldTimeoutTriggered, "Lock %s hold timeout triggered after %s", key, timedOutAfter)
}

// SerializeAll Serializes all key value pairs to a byte array.
Expand Down
2 changes: 1 addition & 1 deletion consul/kv_consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ func (kv *consulKV) renewLockSession(
for {
select {
case <-timeout:
kv.LockTimedout(fmt.Sprintf("Key:%s,Tag:%v", key, tag))
kv.LockTimedout(fmt.Sprintf("Key:%s,Tag:%v", key, tag), lockTimeout)
case <-doneCh:
return
}
Expand Down
2 changes: 1 addition & 1 deletion mem/kv_mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ func (kv *memKV) LockWithTimeout(
for {
select {
case <-timeout:
kv.LockTimedout(key)
kv.LockTimedout(key, lockHoldDuration)
case <-lockChan:
return
}
Expand Down
2 changes: 1 addition & 1 deletion zookeeper/kv_zookeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ func (z *zookeeperKV) waitForUnlock(
}
l.Unlocked = true
}
z.LockTimedout(lockMsgString)
z.LockTimedout(lockMsgString, lockHoldDuration)
return
}
case <-l.Done:
Expand Down

0 comments on commit 18d4792

Please sign in to comment.