fix(cluster): handle MOVED and ASK redirects for atomic MULTI - #3395
Merged
nkaradzhov merged 2 commits intoAug 11, 2026
Merged
Conversation
Route atomic cluster transactions through the existing redirect loop so queue-time MOVED and ASK replies can refresh routing and retry. Keep execAsPipeline on the direct path because it can be partially applied. Pass the redirect chain ID through _executeMulti so ASKING and MULTI/EXEC stay in the same queue chain.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12feb64d8c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
nkaradzhov
approved these changes
Aug 11, 2026
nkaradzhov
left a comment
Collaborator
There was a problem hiding this comment.
Thank you @konovalovsergey, this looks good to go! Appreciate the careful and clean report and fix, its rare these days :D
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.
Description
Fixes #3394.
After a coordinated Redis Cluster failover, the previous primary can remain reachable while returning
MOVEDfor slots owned by the promoted replica. Regular cluster commands recover through the redirect loop, but atomicMULTI/EXECcalled_executeMulti()directly and could not refresh a stale slot map.This change routes atomic cluster transactions through the existing redirect loop so queue-time
MOVEDandASKreplies can refresh routing and retry.execAsPipeline()remains on its direct non-retrying path because a pipeline can be partially applied. The redirectchainIdis passed to_executeMulti()soASKINGandMULTI ... EXECstay in the same queue chain.Only explicit Redis routing errors are retried. Socket errors, timeouts, and other ambiguous failures remain non-retried.
No public API or configuration is changed.
Testing
MULTIafterMOVED.ASKINGand redirectedMULTI.Checklist
npm testpass with this change (including linting)?Note
Medium Risk
Changes cluster transaction routing and retry behavior on redirect errors; scope is limited to atomic MULTI and internal APIs, with explicit tests for MOVED/ASK and failover.
Overview
Fixes stale-slot failures after failover when the old primary still answers with MOVED by routing cluster
multi().exec()through_executeinstead of calling_executeMultion a one-shot client pick._executeMultiaccepts an optionalchainIdfrom the redirect path soASKINGand the retriedMULTI … EXECshare one queue chain.execAsPipeline()is unchanged and still does not retry on MOVED.Docs in
extractCommandsForSlotsnote that atomic MULTI can retry via the redirect loop while non-atomic pipelines do not. Tests cover MOVED retry, ASK chain sharing, pipeline no-retry, and a live failover with a reachable stale master.Reviewed by Cursor Bugbot for commit 8b06219. Bugbot is set up for automated code reviews on this repo. Configure here.