-
Notifications
You must be signed in to change notification settings - Fork 83
Open
Description
This module is awesome, and it's working great!
To detect/prevent issues where the lock seems to be held by a hung block of code, it'd be great if it was possible to set a max number of times the lock could be refreshed.
For example, we just had an issue where we use redis_lock to protect a block of code that generates a shared token, and the token code got hung up:
[INFO] [redis_client] [lock] LOCKING CACHE KEY 'AUTH_TOKEN_KEY.api.userid'
[DEBUG] [redis_client] [lock] the lock ttl: 60
[DEBUG] [redis_client] [lock] ==>ACQUIRING LOCK<== 'AUTH_TOKEN_KEY.api.userid'
[DEBUG] [__init__] [acquire] Acquiring Lock('lock:AUTH_TOKEN_KEY.api.userid') ...
[INFO] [__init__] [acquire] Acquired Lock('lock:AUTH_TOKEN_KEY.api.userid').
[DEBUG] [__init__] [_start_lock_renewer] Starting renewal thread for Lock('lock:AUTH_TOKEN_KEY.api.userid'). Refresh interval: 40.0 seconds.
[DEBUG] [redis_client] [lock] ==>ACQUIRED LOCK<== on 'AUTH_TOKEN_KEY.api.userid'; YIELDING TO CALLER
[DEBUG] [auth_caching] [_fetch_cache_key] fetching cache key 'AUTH_TOKEN_KEY.api.userid'
[DEBUG] [redis_client] [get_key] GETTING CACHE key 'AUTH_TOKEN_KEY.api.userid'
[DEBUG] [redis_client] [get_key] key 'AUTH_TOKEN_KEY.api.userid' => val 'None'
[INFO] [auth_caching] [_get_oauth_token] NO cached token => calling super()._get_oauth_token()
[DEBUG] [__init__] [_lock_renewer] Refreshing Lock('lock:AUTH_TOKEN_KEY.api.userid').
[DEBUG] [__init__] [_lock_renewer] Refreshing Lock('lock:AUTH_TOKEN_KEY.api.userid').
[DEBUG] [__init__] [_lock_renewer] Refreshing Lock('lock:AUTH_TOKEN_KEY.api.userid').
[DEBUG] [__init__] [_lock_renewer] Refreshing Lock('lock:AUTH_TOKEN_KEY.api.userid').
[DEBUG] [__init__] [_lock_renewer] Refreshing Lock('lock:AUTH_TOKEN_KEY.api.userid').
[DEBUG] [__init__] [_lock_renewer] Refreshing Lock('lock:AUTH_TOKEN_KEY.api.userid').
[DEBUG] [__init__] [_lock_renewer] Refreshing Lock('lock:AUTH_TOKEN_KEY.api.userid').
[DEBUG] [__init__] [_lock_renewer] Refreshing Lock('lock:AUTH_TOKEN_KEY.api.userid').
The "Refreshing Lock" message continues for hours until we explicitly deleted the lock key.
Setting a max number of refreshes would be an easy way to prevent a hung code block from keeping the lock forever.
Metadata
Metadata
Assignees
Labels
No labels