Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiving ResponseError: (...) READONLY instead of ReadOnlyError when executing script #3443

Open
goncalossilva opened this issue Nov 27, 2024 · 0 comments

Comments

@goncalossilva
Copy link

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 than ResponseError in this case?
  • Should register_script(...)() runs be retried per retry_on_error?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant