diff --git a/configs/production.ini b/configs/production.ini --- a/configs/production.ini +++ b/configs/production.ini @@ -391,6 +391,8 @@ rc_cache.cache_perms.expiration_time = 3 ; more Redis options: https://dogpilecache.sqlalchemy.org/en/latest/api.html#redis-backends #rc_cache.cache_perms.arguments.distributed_lock = true +; auto-renew lock to prevent stale locks, slower but safer. Use only if problems happen +#rc_cache.cache_perms.arguments.lock_auto_renewal = true ; *************************************************** ; `cache_repo` cache for file tree, Readme, RSS FEEDS @@ -414,6 +416,8 @@ rc_cache.cache_repo.expiration_time = 25 ; more Redis options: https://dogpilecache.sqlalchemy.org/en/latest/api.html#redis-backends #rc_cache.cache_repo.arguments.distributed_lock = true +; auto-renew lock to prevent stale locks, slower but safer. Use only if problems happen +#rc_cache.cache_repo.arguments.lock_auto_renewal = true ; ############## ; BEAKER SESSION diff --git a/rhodecode/lib/rc_cache/backends.py b/rhodecode/lib/rc_cache/backends.py --- a/rhodecode/lib/rc_cache/backends.py +++ b/rhodecode/lib/rc_cache/backends.py @@ -224,6 +224,16 @@ class FileNamespaceBackend(PickleSeriali class BaseRedisBackend(redis_backend.RedisBackend): + key_prefix = '' + + def __init__(self, arguments): + super(BaseRedisBackend, self).__init__(arguments) + self._lock_timeout = self.lock_timeout + self._lock_auto_renewal = arguments.pop("lock_auto_renewal", False) + + if self._lock_auto_renewal and not self._lock_timeout: + # set default timeout for auto_renewal + self._lock_timeout = 60 def _create_client(self): args = {} @@ -289,14 +299,8 @@ class BaseRedisBackend(redis_backend.Red if self.distributed_lock: lock_key = redis_backend.u('_lock_{0}').format(key) log.debug('Trying to acquire Redis lock for key %s', lock_key) - - auto_renewal = True - lock_timeout = self.lock_timeout - if auto_renewal and not self.lock_timeout: - # set default timeout for auto_renewal - lock_timeout = 10 - return get_mutex_lock(self.client, lock_key, lock_timeout, - auto_renewal=auto_renewal) + return get_mutex_lock(self.client, lock_key, self._lock_timeout, + auto_renewal=self._lock_auto_renewal) else: return None