Skip to content

fix(cluster): refresh the slot map when a pipeline gets MOVED - #3560

Merged
nkaradzhov merged 1 commit into
redis:masterfrom
maxymlyskov:fix/refresh-slot-map-on-pipeline-moved
Oct 30, 2026
Merged

nkaradzhov merged 1 commit into
redis:masterfrom
maxymlyskov:fix/refresh-slot-map-on-pipeline-moved

Conversation

@maxymlyskov

@maxymlyskov maxymlyskov commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

After a slot moves to another master (resharding, CLUSTER SETSLOT <slot> NODE <id>), every execAsPipeline() for that slot rejects with MOVED until some single command or multi().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 _executePipeline on the node from the cached map (index.ts#L849-L852) and skips the rediscover that _execute and 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:

  attempt 1 (t+500ms): FAIL MOVED 3638 127.0.0.1:47102
  5/5 attempts failed

With the fix only the first one fails.

Added a testWithCluster case (first pipeline after CLUSTER SETSLOT gets 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 test passes here for every package, and lint is clean.


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

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 on MOVED, without retrying the pipeline.

After resharding, pipeline-only workloads could stay stuck: MOVED from multi().execAsPipeline() was propagated without calling _slots.rediscover(), unlike single commands and multi().exec(). The pipeline path still does not retry (partial execution risk), but on ErrorReply starting with MOVED it awaits rediscover(client) (errors from refresh are swallowed) and rethrows the original error. ASK in a pipeline is unchanged—no refresh.

Tests were updated to expect one rediscovery on MOVED, plus unit cases for failed refresh and no refresh on ASK, and a testWithCluster case 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.

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.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-29T16:34:29.529942Z da6c9fa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@nkaradzhov nkaradzhov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

@nkaradzhov
nkaradzhov merged commit ced3da6 into redis:master Oct 30, 2026
15 checks passed
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.

2 participants