From 7c85e92eb50097cff45ac5bef274586093116912 Mon Sep 17 00:00:00 2001 From: snower Date: Sun, 21 Apr 2024 23:10:20 +0800 Subject: [PATCH] Fixed the problem of updating lock data to perform rewrite operation by immediately expiring Lock command. --- server/db.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/db.go b/server/db.go index da84e71..fc10a4d 100755 --- a/server/db.go +++ b/server/db.go @@ -2326,11 +2326,6 @@ func (self *LockDB) HasLock(command *protocol.LockCommand, aofLockData []byte) b lockManager.glock.Unlock() return false } - currentLock := lockManager.GetLockedLock(command) - if currentLock == nil { - lockManager.glock.Unlock() - return false - } if command.ExpriedFlag&0x4440 == 0 && command.Expried == 0 { if aofLockData == nil || lockManager.currentData == nil || lockManager.currentData.data == nil || len(aofLockData) != len(lockManager.currentData.data) { lockManager.glock.Unlock() @@ -2343,6 +2338,13 @@ func (self *LockDB) HasLock(command *protocol.LockCommand, aofLockData []byte) b return false } } + lockManager.glock.Unlock() + return true + } + currentLock := lockManager.GetLockedLock(command) + if currentLock == nil { + lockManager.glock.Unlock() + return false } lockManager.glock.Unlock() return true