Skip to content

Fixed issue with moved command for replicas#2059

Merged
PavelPashov merged 7 commits intoredis:mainfrom
DevandScorp:DevandScorp/fix/issue-with-moved-command-for-replicas
Jan 15, 2026
Merged

Fixed issue with moved command for replicas#2059
PavelPashov merged 7 commits intoredis:mainfrom
DevandScorp:DevandScorp/fix/issue-with-moved-command-for-replicas

Conversation

@DevandScorp
Copy link
Contributor

@DevandScorp DevandScorp commented Jan 12, 2026

Hi, I was fighting with the issue All keys in the pipeline should belong to the same slots allocation group for quite a lot of time.
Obviously this validation message can appear when smth is happening on the cluster and ioredis need some time to recalculate slots mapping. But in my case the cluster remained stable, and this validation messages were randomly shown on different instances of the application.
My PR has fixed the issue for the following scenario:

  1. My Redis setup is: enabled sharding + read replica for each master node.
  2. scaleReads = all + enableAutoPipelining = true
  3. ioredis is executing a https://redis.io/docs/latest/commands/readonly/ command for all read replicas in order to avoid MOVED messages.
  4. Sometimes READONLY command can be executed after several get operations already made on the replica(just some race condition, which can easily happen when we have enableOfflineQueue and lazyConnect features enabled). In this case I receive MOVED <slot-number> <master-node-host> response.
  5. MOVED command is not crucial, but the way moved command is handled is. Currently ioredis is rewriting a slot map without checking what is happening in the slot. With read replicas slot map's value is ['master-node-host', ...]. After rewriting it with the master's node address only future validations will fail on generateMultiWithNodes before a slots map refresh.

I hope this fix will help a lot of users to stop receiving issues on the same setup I've described.

@jit-ci
Copy link

jit-ci bot commented Jan 12, 2026

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@DevandScorp DevandScorp marked this pull request as ready for review January 12, 2026 14:44
@DevandScorp
Copy link
Contributor Author

@PavelPashov hi, possibly my PR should fix this issue #1734, I'm not sure that I know the way to attach this issue to the PR).

@PavelPashov
Copy link
Contributor

@DevandScorp Thanks for the PR, looks good overall. CI is currently failing due to the new tests. Can you take a look and push a fix?

@DevandScorp
Copy link
Contributor Author

@PavelPashov hi, I made a fix, hopefully it will work.

@DevandScorp
Copy link
Contributor Author

@PavelPashov hi, it seems to me that all tests have passed, is there anything else needed from my side?

PavelPashov
PavelPashov previously approved these changes Jan 15, 2026
Copy link
Contributor

@PavelPashov PavelPashov left a comment

Choose a reason for hiding this comment

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

Looks good, thank you for the contribution

@jit-ci
Copy link

jit-ci bot commented Jan 15, 2026

❌ Security scan failed

Security scan failed: Branch DevandScorp/fix/issue-with-moved-command-for-replicas does not exist in the remote repository


💡 Need to bypass this check? Comment @sera bypass to override.

@PavelPashov PavelPashov self-requested a review January 15, 2026 11:24
@PavelPashov PavelPashov dismissed their stale review January 15, 2026 11:27

Incorrect review

@jit-ci
Copy link

jit-ci bot commented Jan 15, 2026

❌ Security scan failed

Security scan failed: Branch DevandScorp/fix/issue-with-moved-command-for-replicas does not exist in the remote repository


💡 Need to bypass this check? Comment @sera bypass to override.

@PavelPashov PavelPashov merged commit a1c3e9d into redis:main Jan 15, 2026
11 checks passed
PavelPashov added a commit to PavelPashov/ioredis that referenced this pull request Jan 15, 2026
github-actions bot pushed a commit that referenced this pull request Jan 15, 2026
## [5.9.2](v5.9.1...v5.9.2) (2026-01-15)

### Bug Fixes

* **cluster:** Cluster reconnect sharded subscribers ([#2060](#2060)) ([def9804](def9804))
* preserve replica slots on MOVED in pipelines ([#2059](#2059)) ([a1c3e9d](a1c3e9d))

### Reverts

* Revert "fix: preserve replica slots on MOVED in pipelines (#2059)" (#2062) ([517b932](517b932)), closes [#2059](#2059) [#2062](#2062)
@github-actions
Copy link

🎉 This PR is included in version 5.9.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

PavelPashov added a commit to PavelPashov/ioredis that referenced this pull request Jan 15, 2026
PavelPashov added a commit to PavelPashov/ioredis that referenced this pull request Jan 15, 2026
This was referenced Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants