summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2017-08-14 10:18:09 +0200
committerJulien Danjou <julien@danjou.info>2017-08-14 10:18:09 +0200
commit3f25d41182a26e522a9805a17729295777a89728 (patch)
tree4a057c957f80f88b33ee268cbc3599bb49c0cb43
parenta25815d9a89e990c16d40b8312b6772937f2975c (diff)
downloadtooz-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.py3
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):