redis: always remove lock from acquired lock when release()ing
The failure scenarios where LockError is raised is either: - Lock is not locked. Then it should not be in _acquired_locks, so discard should be a no-op. - Token changed. That can happen if the lock timed-out (and somebody else grabbed it). Then the lock is not longer owned anyway so let's remove it. If releasing the lock fails, there's no way heartbeat will work anyway. So just remove the lock from acquired locks and let it die anyway. Change-Id: I44db39e83db7e6c0f17079584e49c8de34b51ce1
This commit is contained in:
parent
a25815d9a8
commit
3f25d41182
|
@ -102,7 +102,8 @@ class RedisLock(locking.Lock):
|
|||
except exceptions.LockError as e:
|
||||
LOG.error("Unable to release lock '%r': %s", self, e)
|
||||
return False
|
||||
self._coord._acquired_locks.discard(self)
|
||||
finally:
|
||||
self._coord._acquired_locks.discard(self)
|
||||
return True
|
||||
|
||||
def heartbeat(self):
|
||||
|
|
Loading…
Reference in New Issue