recognise read only error returned from Lua script#2770
Closed
zhengjilei wants to merge 2 commits into
Closed
Conversation
Collaborator
|
Hey, |
ndyakov
requested changes
Apr 23, 2025
ndyakov
left a comment
Member
There was a problem hiding this comment.
Please check and address the comments that were left from @ofekshenawa and me.
|
|
||
| // For a Lua script that includes a write command, the error string | ||
| // contains "-READONLY" rather than beginning with "READONLY " | ||
| return strings.Contains(redisError, "-READONLY") |
Member
There was a problem hiding this comment.
Can we be more strict here? I assume one can easily use a command with working on a "something-readonly" key and trigger an error that will return true for containing "-readonly"
Member
|
Closing this for inactivity. |
zhengjilei
added a commit
to zhengjilei/go-redis
that referenced
this pull request
Apr 8, 2026
…icas When a Lua script containing a write command is executed against a read-only replica in older Redis versions (< 7.0), the error is wrapped: "ERR Error running script ...: @user_script:N: -READONLY ..." The existing code only checked for the "READONLY " prefix, missing this embedded format. This caused shouldRetry() and isReadOnlyError() to fail, preventing automatic retry and connection pool cleanup. The fix uses strings.Contains(s, " -READONLY ") with surrounding spaces to match the Lua error wrapping pattern while avoiding false positives from key names containing "-READONLY" (addressing reviewer feedback from PR redis#2770). Closes redis#2770 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 tasks
zhengjilei
added a commit
to zhengjilei/go-redis
that referenced
this pull request
Apr 8, 2026
…icas When a Lua script containing a write command is executed against a read-only replica in older Redis versions (< 7.0), the error is wrapped: "ERR Error running script ...: @user_script:N: -READONLY ..." The existing code only checked for the "READONLY " prefix, missing this embedded format. This caused shouldRetry() and isReadOnlyError() to fail, preventing automatic retry and connection pool cleanup. The fix checks for both "ERR Error running script" prefix and "-READONLY" substring, ensuring only Lua script errors are matched (addressing reviewer feedback from PR redis#2770). Closes redis#2770 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
zhengjilei
added a commit
to zhengjilei/go-redis
that referenced
this pull request
Apr 8, 2026
…icas When a Lua script containing a write command is executed against a read-only replica in a Redis Cluster, the error may contain "-READONLY You can't write against a read only replica" embedded within a larger error message rather than starting with "READONLY ". The existing code only checked for the "READONLY " prefix, missing this format. This caused shouldRetry() and isReadOnlyError() to fail, preventing automatic retry and connection pool cleanup. The fix checks for the exact substring "-READONLY You can't write against a read only replica" which is specific enough to avoid false positives while catching the Lua script error format. Closes redis#2770 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ndyakov
pushed a commit
that referenced
this pull request
Apr 9, 2026
…icas (#3769) When a Lua script containing a write command is executed against a read-only replica in a Redis Cluster, the error may contain "-READONLY You can't write against a read only replica" embedded within a larger error message rather than starting with "READONLY ". The existing code only checked for the "READONLY " prefix, missing this format. This caused shouldRetry() and isReadOnlyError() to fail, preventing automatic retry and connection pool cleanup. The fix checks for the exact substring "-READONLY You can't write against a read only replica" which is specific enough to avoid false positives while catching the Lua script error format. Closes #2770 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.