From 0b86439963c837b08ddfc43a5013024d4f43386b Mon Sep 17 00:00:00 2001 From: stulzq Date: Fri, 11 Mar 2022 12:46:47 +0800 Subject: [PATCH] fix bug --- components/lock/in-memory/in_memory_lock.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/lock/in-memory/in_memory_lock.go b/components/lock/in-memory/in_memory_lock.go index a64f50f985..deaf4c4e18 100644 --- a/components/lock/in-memory/in_memory_lock.go +++ b/components/lock/in-memory/in_memory_lock.go @@ -65,15 +65,16 @@ func (s *InMemoryLock) TryLock(req *lock.TryLockRequest) (*lock.TryLockResponse, item, ok := s.data.locks[req.ResourceId] if !ok { item = &memoryLock{ - key: req.ResourceId, + key: req.ResourceId, //0 unlock, 1 lock lock: 0, } s.data.locks[req.ResourceId] = item } + // 2. Construct a new one if the lockData has expired //check expire - if item.owner != "" && time.Now().Before(item.expireTime) { + if item.owner != "" && time.Now().After(item.expireTime) { item = &memoryLock{ key: req.ResourceId, lock: 0,