diff options
author | Julien Danjou <julien@danjou.info> | 2017-08-14 10:18:09 +0200 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2017-08-14 10:18:09 +0200 |
commit | 3f25d41182a26e522a9805a17729295777a89728 (patch) | |
tree | 4a057c957f80f88b33ee268cbc3599bb49c0cb43 | |
parent | a25815d9a89e990c16d40b8312b6772937f2975c (diff) | |
download | tooz-3f25d41182a26e522a9805a17729295777a89728.tar.gz |
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
-rw-r--r-- | tooz/drivers/redis.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tooz/drivers/redis.py b/tooz/drivers/redis.py index 00a0ba7..d3cf4f6 100644 --- a/tooz/drivers/redis.py +++ b/tooz/drivers/redis.py @@ -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): |