-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Retrying on timeouts not working when executing Redis Pipeline #2811
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
6 tasks
I note that this bug also affects instances of Example for demonstration. For redis-py<=4.0.2 this listens "forever".
Possible fixes:
|
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Version: 4.5.5
Platform: Python 3.10.10, Ubuntu 22.04
Description:
When the
Redis
client is initialized withretry_on_timeout
set toTrue
orretry_on_error
set to[redis.exceptions.TimeoutError, socket.timeout]
andconnection_pool
is not provided, the timeout retrying does not work in client's pipeline execution.For example:
Problem found:
Inside
Redis
init method onlyretry_on_error
is propagated through newly createdkwargs
into the createdConnectionPool
(line 1043 inredis/client.py
) withretry_on_timeout
causingTimeoutError
to be added toretry_on_error
(line 988 inredis/client.py
).Subsequently, when a Redis Pipeline is initialized from the client using the
pipeline
method (1096 inredis/client.py
), it is initialized using theConnectionPool
created in theRedis
constructor.When we execute the pipeline using the
execute
method (line 2100 inredis/client.py
),conn.retry.call_with_retry
will be called, whereconn
is aConnection
object initiated from theConnectionPool
withretry_on_error
set, andretry_on_timeout
not set as it was not propagated intoConnectionPool
and thus toConnection
.When a timeout occurs while executing the pipeline,
_disconnect_raise_reset(conn, error)
method of the Redis Pipeline is called (line2080
inredis/client.py
). The problem with this method is that it will always re-raise theTimeoutError
due toconn.retry_on_timeout
always beingFalse
. The reason is thatconn
was created from theConnectionPool
, which was initialized withoutretry_on_timeout
being set (in theRedis
constructor).Possible fix:
Use
retry_on_error
instead ofretry_on_timeout
inside_disconnect_raise_reset
.The text was updated successfully, but these errors were encountered: