Skip to content

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

Open
@goncalossilva

Description

@goncalossilva

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions