Repository navigation
fix(cluster): refresh the slot map when a pipeline gets MOVED - #3560
Merged
nkaradzhov merged 1 commit intoOct 30, 2026
Merged
Conversation
execAsPipeline() sends the batch straight to the node from the slot map, so a MOVED reply never reaches the rediscover that single commands and MULTI get from the redirect loop. After a slot moved, every pipeline for it failed with MOVED until some other command refreshed the map. The pipeline is still not retried, as decided in redis#3395 (it can be partially applied). On MOVED it now refreshes the slot map and rejects with the original error, also when the refresh itself fails.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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
After a slot moves to another master (resharding,
CLUSTER SETSLOT <slot> NODE <id>), everyexecAsPipeline()for that slot rejects with MOVED until some single command ormulti().exec()hits MOVED and refreshes the slot map. A node that stays up never triggers the reconnect refresh, so a pipeline-only workload never recovers.The pipeline executor calls
_executePipelineon the node from the cached map (index.ts#L849-L852) and skips therediscoverthat_executeand SSUBSCRIBE do on MOVED.#3395 ruled out the retry ("Keep execAsPipeline on the direct path because it can be partially applied"), not the refresh. Its test also asserted no rediscover, so I changed that assertion to one and renamed the test. It still checks the pipeline is sent once.
On MOVED the executor now awaits
rediscover(client)and rethrows the original error, even if the refresh fails. ASK is left alone.Repro on a local 3-master cluster, 5 pipelines after moving a slot, on master:
With the fix only the first one fails.
Added a
testWithClustercase (first pipeline afterCLUSTER SETSLOTgets MOVED, the second goes through) and unit tests for a failed refresh and for ASK. The cluster test fails on master.npm run build && npm testpasses here for every package, and lint is clean.Checklist
npm testpass with this change (including linting)?Note
Medium Risk
Changes cluster routing behavior on MOVED for non-atomic pipelines; scope is narrow (refresh only, no retry) but affects production resharding recovery paths.
Overview
Cluster
execAsPipeline()now refreshes the slot map onMOVED, without retrying the pipeline.After resharding, pipeline-only workloads could stay stuck:
MOVEDfrommulti().execAsPipeline()was propagated without calling_slots.rediscover(), unlike single commands andmulti().exec(). The pipeline path still does not retry (partial execution risk), but onErrorReplystarting withMOVEDit awaitsrediscover(client)(errors from refresh are swallowed) and rethrows the original error.ASKin a pipeline is unchanged—no refresh.Tests were updated to expect one rediscovery on
MOVED, plus unit cases for failed refresh and no refresh onASK, and atestWithClustercase where the first pipeline fails and the second succeeds after the map updates.Reviewed by Cursor Bugbot for commit da6c9fa. Bugbot is set up for automated code reviews on this repo. Configure here.