You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform:
Python 3.12.2 running on Debian bookworm
Description:
First off I want to say thanks for maintaining this library :)
So to the issue at hand:
It seems like the retry-functionality in the PubSub-client (both async and sync) is not working correctly.
To simulate a crash of redis I am closing and restarting redis while our system is running. Even though our connection is set up with an infinite amount of retry, the PubSub-client always crashes and never recovers.
Having dug though the source code I have found the pathways causing the crash.
The _execute-function runs periodicially, and whenever redis is closed the command fails.
This causes the _disconnect_raise_connect-function to be called:
_disconnect_raise_connect closes the connection, conn.retry_on_error is True making the function skip raising error.
This is followed by an attempt at reconnecting.
# causing an error. Do not leave the connection open.
writer.close()
raise
Inside the _connect-function an attempt is made to connect to redis. Since redis is unavailable an OSError is created. OSError is not in the list of supported_errors causing it to bypass the error handling in the call_with_retry-function and is propagated to the connect-function. Here it is converted to a ConnectionError and is propagated all the way to the top unhandled.
Is this intended behaviour?
Is this something that could be handled in a different way?
We have temporarily fixed this by adding OSError to the list of supported_errors, but this feels like quite a hacky solution.
The text was updated successfully, but these errors were encountered:
Version:
redis-py: 5.0.3
redis: 7.2.4
Platform:
Python 3.12.2 running on Debian bookworm
Description:
First off I want to say thanks for maintaining this library :)
So to the issue at hand:
It seems like the retry-functionality in the PubSub-client (both async and sync) is not working correctly.
To simulate a crash of redis I am closing and restarting redis while our system is running. Even though our connection is set up with an infinite amount of retry, the PubSub-client always crashes and never recovers.
Having dug though the source code I have found the pathways causing the crash.
redis-py/redis/asyncio/client.py
Lines 885 to 896 in 1784b37
The
_execute
-function runs periodicially, and whenever redis is closed the command fails.This causes the
_disconnect_raise_connect
-function to be called:redis-py/redis/asyncio/client.py
Lines 870 to 883 in 1784b37
_disconnect_raise_connect
closes the connection,conn.retry_on_error
isTrue
making the function skip raising error.This is followed by an attempt at reconnecting.
redis-py/redis/asyncio/connection.py
Lines 269 to 284 in 1784b37
Since we are not currently connected, the first if-statement is
False
. A call with retry is made to the_connect
-function.redis-py/redis/asyncio/connection.py
Lines 678 to 700 in 1784b37
Inside the
_connect
-function an attempt is made to connect to redis. Since redis is unavailable anOSError
is created.OSError
is not in the list ofsupported_errors
causing it to bypass the error handling in thecall_with_retry
-function and is propagated to theconnect
-function. Here it is converted to aConnectionError
and is propagated all the way to the top unhandled.Is this intended behaviour?
Is this something that could be handled in a different way?
We have temporarily fixed this by adding
OSError
to the list ofsupported_errors
, but this feels like quite a hacky solution.The text was updated successfully, but these errors were encountered: