Skip to content

redis: close the connection on READONLY replies to pipelined commands - #1297

Open
OS-diogofernandes wants to merge 1 commit into
envoyproxy:mainfrom
OS-diogofernandes:readonly-pipeline-close-conn
Open

OS-diogofernandes wants to merge 1 commit into
envoyproxy:mainfrom
OS-diogofernandes:readonly-pipeline-close-conn

Conversation

@OS-diogofernandes

@OS-diogofernandes OS-diogofernandes commented Nov 4, 2026 •

Copy link
Copy Markdown

REDIS_CLOSE_CONNECTION_ON_READONLY_ERROR (#1191) has no effect on pipelined commands, which is how the counters are written (INCRBY + EXPIRE). radix keeps each command's error on the command and returns nil to the connection, so readOnlyClosingConn never sees the READONLY reply and the pool keeps reusing the connection to the demoted server.

This adds a pipeline action that returns resp.ErrConnUnusable on a READONLY reply, so the pool discards the connection. It is used in single and sentinel mode when the option is on; nothing changes when it is off.

Notes:

  • The new type mirrors radix v4's unexported pipeline, so it needs a look on radix upgrades.
  • Cluster mode is not changed (documented in the README).

Related: #1256, an earlier draft for the same problem.

@OS-diogofernandes
OS-diogofernandes marked this pull request as ready for review November 4, 2026 15:49
REDIS_CLOSE_CONNECTION_ON_READONLY_ERROR does not apply to pipelines.
radix keeps the error of each pipelined command on the command and
returns nil to the connection, so readOnlyClosingConn never sees the
READONLY reply and the pool keeps the connection to the demoted server.
Counters are written with a pipelined INCRBY and EXPIRE, so after a
failover that leaves the old master running, every write keeps failing
until the service restarts.

Add a pipeline action that returns resp.ErrConnUnusable when a reply is
READONLY, and use it in single and sentinel mode when the option is on.
Cluster mode is unchanged.

Signed-off-by: Diogo Fernandes <diogo.fernandes@outsystems.com>
@OS-diogofernandes
OS-diogofernandes force-pushed the readonly-pipeline-close-conn branch from c0864c9 to a66c4ba Compare November 4, 2026 15:56
@OS-diogofernandes

Copy link
Copy Markdown
Author

Hello @envoyproxy/ratelimit-maintainers (@agrawroh, @collin-lee), can you take a look at this PR? Thank you

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

Successfully merging this pull request may close these issues.

1 participant