Skip to content

Fix autopipelining to route writes to masters with scaleReads#2072

Merged
PavelPashov merged 1 commit intoredis:mainfrom
ivoronin:fix-autopipelining
Jan 30, 2026
Merged

Fix autopipelining to route writes to masters with scaleReads#2072
PavelPashov merged 1 commit intoredis:mainfrom
ivoronin:fix-autopipelining

Conversation

@ivoronin
Copy link
Copy Markdown
Contributor

When scaleReads is set to slave or all and enableAutoPipelining is enabled, writes may end up going to replicas instead of masters.

The problem is that autopipelining groups commands by slot into a single pipeline, and that pipeline goes to whatever node scaleReads picks - which can be a replica.

This causes the whole pipeline to fail and retry with MOVED redirects until by luck it lands on a master, stacking up latency. In the worst case (after 16 failed attempts) these MOVED errors bubble up to user code.

The fix separates read and write commands into different pipelines when scaleReads is not master. Read commands get a :read suffix on their slot key, writes get :write. This way they end up in separate pipelines that route correctly.

@jit-ci
Copy link
Copy Markdown

jit-ci bot commented Jan 30, 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.

Copy link
Copy Markdown
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.

This looks good, thank you for your contribution

@PavelPashov PavelPashov merged commit 8adb1ae into redis:main Jan 30, 2026
11 checks passed
@ivoronin
Copy link
Copy Markdown
Contributor Author

ivoronin commented Feb 2, 2026

@PavelPashov Could I ask you for a minor release?

@ivoronin ivoronin deleted the fix-autopipelining branch February 5, 2026 08:42
@PavelPashov
Copy link
Copy Markdown
Contributor

@PavelPashov Could I ask you for a minor release?

@ivoronin I'm planning to do a minor release next week, as there're other fixes/features that would be great if included

github-actions bot pushed a commit that referenced this pull request Feb 12, 2026
## [5.9.3](v5.9.2...v5.9.3) (2026-02-12)

### Bug Fixes

* autopipelining to route writes to masters with scaleReads ([#2072](#2072)) ([8adb1ae](8adb1ae))
* fix issue with moved command for replicas ([#2064](#2064)) ([de4eed4](de4eed4))
* **types:** optional properties on RedisOptions allow explicit undefined ([#2066](#2066)) ([0a1a898](0a1a898))
github-actions bot pushed a commit that referenced this pull request Feb 12, 2026
## [5.9.3](v5.9.2...v5.9.3) (2026-02-12)

### Bug Fixes

* autopipelining to route writes to masters with scaleReads ([#2072](#2072)) ([8adb1ae](8adb1ae))
* fix issue with moved command for replicas ([#2064](#2064)) ([de4eed4](de4eed4))
* **types:** optional properties on RedisOptions allow explicit undefined ([#2066](#2066)) ([0a1a898](0a1a898))
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 5.9.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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