File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
packages/service-library/src/servicelib/redis Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change 11import asyncio
2- import contextlib
32import functools
43import logging
54import socket
109import arrow
1110import redis .exceptions
1211from redis .asyncio .lock import Lock
12+ from servicelib .logging_errors import create_troubleshootting_log_kwargs
1313
1414from ..background_task import periodic
1515from ._client import RedisClientSDK
@@ -138,10 +138,21 @@ async def _wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
138138 # in the case where the lock would have been lost,
139139 # this would raise again and is not necessary
140140 await lock .release ()
141- except redis .exceptions .LockNotOwnedError :
141+ except redis .exceptions .LockNotOwnedError as exc :
142142 _logger .exception (
143- "Unexpected error with lock '%s', cannot release it" ,
144- redis_lock_key ,
143+ ** create_troubleshootting_log_kwargs (
144+ f"Unexpected error while releasing lock '{ redis_lock_key } '" ,
145+ error = exc ,
146+ error_context = {
147+ "redis_lock_key" : redis_lock_key ,
148+ "lock_value" : lock_value ,
149+ "client_name" : client .client_name ,
150+ "hostname" : socket .gethostname (),
151+ "coroutine" : coro .__name__ ,
152+ },
153+ tip = "This might happen if the lock was lost before releasing it. "
154+ "Look for synchronous code that prevents refreshing the lock or asyncio loop overload." ,
155+ )
145156 )
146157
147158 return _wrapper
You can’t perform that action at this time.
0 commit comments