Description
Version
redis-py 5.2.0 with Redis 6.2.6
Platform
Python 3.11.3 on the latest respective docker image (python:$PYTHON_VERSION
)
Description
Our code executes lua scripts, that contain various instructions (e.g., rpush
). We have set up retry_on_error
with a few errors, including ReadOnlyError
, to more gracefully handle failovers. However, and specifically in the case of executing a script, the error will be the more general ResponseError
and not ReadOnlyError
.
A simplified example would be:
script = redis_client.register_script(script_text)
result = script(args=arg_list)
And if the script fails (e.g., rpush
when the instance of read-only), the connection is not retried, I presume because the error is not ReadOnlyError
, but ResponseError
instead:
ResponseError: Error running script (call to f_1e84a64d649a247ba53ce64b0be7bbedd64fe1b4): @user_script:28: @user_script: 28: -READONLY You can't write against a read only replica.
(line 28 is rpush
in this case)
I'm not sure if this is a bug or working as intended, it depends on:
- Is
ReadOnlyError
more appropriate thanResponseError
in this case? - Should
register_script(...)()
runs be retried perretry_on_error
?