Avoid redis lock's expire_time exceeding timeout.
After n heartbeats, the expireation time of the lock key becomes (1 + 0.5n) * timeout! Therefore, when the lock holder performs a long task and exits abnormally, the lock will not be automatically released in time. Change-Id: I2437071bb575e95083b0d57a6a0a33aaf8356113
This commit is contained in:
parent
ff33fe783f
commit
20bda6ed99
|
@ -52,7 +52,7 @@ etcd3gw =
|
|||
zake =
|
||||
zake>=0.1.6 # Apache-2.0
|
||||
redis =
|
||||
redis>=2.10.0 # MIT
|
||||
redis>=3.1.0 # MIT
|
||||
postgresql =
|
||||
psycopg2>=2.5 # LGPL/ZPL
|
||||
mysql =
|
||||
|
|
|
@ -110,7 +110,7 @@ class RedisLock(locking.Lock):
|
|||
with self._exclusive_access:
|
||||
if self.acquired:
|
||||
with _translate_failures():
|
||||
self._lock.extend(self._lock.timeout)
|
||||
self._lock.reacquire()
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in New Issue