##// END OF EJS Templates
cache: allow controlling lock_auto_renewal via .ini config
super-admin -
r949:6224e9fb default
parent child Browse files
Show More
@@ -154,6 +154,9 b' rc_cache.repo_object.expiration_time = 2'
154 ; more Redis options: https://dogpilecache.sqlalchemy.org/en/latest/api.html#redis-backends
154 ; more Redis options: https://dogpilecache.sqlalchemy.org/en/latest/api.html#redis-backends
155 #rc_cache.repo_object.arguments.distributed_lock = true
155 #rc_cache.repo_object.arguments.distributed_lock = true
156
156
157 ; auto-renew lock to prevent stale locks, slower but safer. Use only if problems happen
158 #rc_cache.repo_object.arguments.lock_auto_renewal = true
159
157 ; Statsd client config
160 ; Statsd client config
158 #statsd.enabled = false
161 #statsd.enabled = false
159 #statsd.statsd_host = 0.0.0.0
162 #statsd.statsd_host = 0.0.0.0
@@ -189,6 +189,16 b' class FileNamespaceBackend(PickleSeriali'
189
189
190
190
191 class BaseRedisBackend(redis_backend.RedisBackend):
191 class BaseRedisBackend(redis_backend.RedisBackend):
192 key_prefix = ''
193
194 def __init__(self, arguments):
195 super(BaseRedisBackend, self).__init__(arguments)
196 self._lock_timeout = self.lock_timeout
197 self._lock_auto_renewal = arguments.pop("lock_auto_renewal", False)
198
199 if self._lock_auto_renewal and not self._lock_timeout:
200 # set default timeout for auto_renewal
201 self._lock_timeout = 60
192
202
193 def _create_client(self):
203 def _create_client(self):
194 args = {}
204 args = {}
@@ -254,14 +264,8 b' class BaseRedisBackend(redis_backend.Red'
254 if self.distributed_lock:
264 if self.distributed_lock:
255 lock_key = redis_backend.u('_lock_{0}').format(key)
265 lock_key = redis_backend.u('_lock_{0}').format(key)
256 log.debug('Trying to acquire Redis lock for key %s', lock_key)
266 log.debug('Trying to acquire Redis lock for key %s', lock_key)
257
267 return get_mutex_lock(self.client, lock_key, self._lock_timeout,
258 auto_renewal = True
268 auto_renewal=self._lock_auto_renewal)
259 lock_timeout = self.lock_timeout
260 if auto_renewal and not self.lock_timeout:
261 # set default timeout for auto_renewal
262 lock_timeout = 10
263 return get_mutex_lock(self.client, lock_key, lock_timeout,
264 auto_renewal=auto_renewal)
265 else:
269 else:
266 return None
270 return None
267
271
General Comments 0
You need to be logged in to leave comments. Login now