GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Scan only primary nodes in scanIteration on cluster by RaphaelFakhri · Pull Request #4798 · redis/jedis

Conversation

@RaphaelFakhri

@RaphaelFakhri RaphaelFakhri commented Oct 19, 2026 •
edited by cursor Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

On a cluster with replicas, scanIteration returns every key once from its primary and again from each replica. JedisCommandIterationBase now iterates getPrimaryNodesConnectionMap() instead of getConnectionMap(), so SCAN runs once per shard. This matches how KEYS and other all-shards commands are broadcast. Fixes #4797.

Key decisions and assumptions

  • The change is in the shared iteration base, so ftSearchIteration and ftAggregateIteration also stop querying replicas.
  • MultiDbConnectionProvider overrides only getConnectionMap(). Without an override, getPrimaryNodesConnectionMap() falls back to the interface default, which borrows a connection that is never returned to the pool. The provider now returns the active database pool from both methods.
  • Standalone, pooled and Sentinel providers already return the same map from both methods, so their behavior does not change.

Behavioral changes

  • On cluster, scanIteration returns each key once. With 3 primaries and 1 replica each, 100 keys previously came back as 200.
  • Release notes entry added under "Behavior Changes" in docs/release-notes/8.1.0.md.

Testing

testScanIterationSkipsReplicas mocks a provider whose all-nodes map has a primary and a replica and whose primary map has only the primary, and asserts that each key is returned once. The test fails without the fix (key1, key2, key1, key2) and passes with it. The two existing scanIteration mocked tests now stub the primary-nodes map. Checked by hand against a Redis 8.2 cluster with 3 primaries and 3 replicas: 200 keys before the fix, 100 after.


Note

Medium Risk
Changes cluster iteration behavior for scan and related iterators; fixes incorrect duplicates but is a user-visible semantic change for replica-heavy setups.

Overview
Fixes duplicate keys from scanIteration on Redis Cluster when replicas are included in the provider’s node map. JedisCommandIterationBase now builds its per-node round-robin from getPrimaryNodesConnectionMap() instead of getConnectionMap(), so SCAN runs once per shard (same idea as other all-shard commands). That also applies to iteration helpers built on the same base (e.g. FT search/aggregate iterations).

On ConnectionProvider, the default getPrimaryNodesConnectionMap() delegates to getConnectionMap() (with docs) so standalone/pooled providers keep the same behavior; cluster providers that override the primary map exclude replicas.

Tests stub the primary map for existing scanIteration mocks, add testScanIterationSkipsReplicas, and assert the interface default matches getConnectionMap().

Reviewed by Cursor Bugbot for commit 25ca6df. Bugbot is set up for automated code reviews on this repo. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@RaphaelFakhri
Scan only primary nodes in scanIteration on cluster
df932b9
On a cluster with replicas, the command iteration base ran SCAN on every
known node, so each key was returned by its primary and again by every
replica. Iterate the primary nodes map instead, matching how KEYS and
other all-shards commands are broadcast. MultiDbConnectionProvider now
overrides getPrimaryNodesConnectionMap so it keeps using the active
database pool instead of the interface default.
@RaphaelFakhri
RaphaelFakhri force-pushed the fix-scan-iteration-primaries branch from 7fe093e to df932b9 Compare October 19, 2026 09:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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 ✅ Completed 2026-10-19T14:39:25.755620Z 25ca6df New commits
ℹ️ 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Oct 19, 2026
View reviewed changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fe093ef70

ℹ️ 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".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/redis/clients/jedis/util/JedisCommandIterationBase.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread docs/release-notes/8.1.0.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ggivo ggivo added the waiting-for-triage Still needs to be triaged label Oct 19, 2026
This was referenced Oct 19, 2026
Iterations on MultiDbClient leak a pooled connection #4799
Closed
Iterations on MultiDbClient return their pooled connections #4800
Merged
ggivo added a commit that referenced this pull request Oct 19, 2026
@ggivo @RaphaelFakhri
Iterations on MultiDbClient return their pooled connections (#4800)
4bc72cc
* Return pooled connections from iterations on MultiDbClient

MultiDbConnectionProvider overrode getConnectionMap() but not
getPrimaryNodesConnectionMap(), so the interface default borrowed a
pooled connection that AggregateIterator treated as caller-owned and
never returned; each ftAggregateIterator call leaked one connection
until the pool was exhausted. Return the active database's pool from
both methods.

The ITs also cover scanIteration and ftAggregateIteration, which switch
to the primaries map in #4798. Fixes #4799.

Co-authored-by: Raphael Fakhri <[email protected]>

* Share the MultiDbClient active-pool test helper

Five tests copied the same lookup of the active database's connection pool. MultiDbConnectionProviderHelper.activeConnectionPool replaces them; test code only.

---------

Co-authored-by: Raphael Fakhri <[email protected]>
ggivo added 2 commits October 19, 2026 16:16
@ggivo
Merge branch 'master' into fix-scan-iteration-primaries
27ab24e
# Conflicts:
#	docs/release-notes/8.1.0.md
@ggivo
Drop the release-notes entry
f416959
A bug fix with no action required from users.
@ggivo

ggivo commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Pushed 27ab24e and f416959 on top of your branch: merged master, which now carries the MultiDbConnectionProvider override and the MultiDb iteration ITs via #4800 (extracted from this PR, with you as co-author), and dropped the release-notes entry since this is a bug fix with no action required. The remaining diff is the JedisCommandIterationBase switch and its unit test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Oct 19, 2026
View reviewed changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4169596db

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/redis/clients/jedis/util/JedisCommandIterationBase.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ggivo ggivo added bug and removed waiting-for-triage Still needs to be triaged labels Oct 19, 2026
@ggivo ggivo added this to the 8.1.0 milestone Oct 19, 2026
@ggivo
Default getPrimaryNodesConnectionMap to getConnectionMap
25ca6df
The default returned a single getConnection() connection and ignored any
getConnectionMap() override; with a pooled provider that connection is
borrowed and never returned (redis#4323, redis#4799). Now that iterations read the
primaries map, a custom provider overriding only getConnectionMap()
would iterate one node through such a connection. Built-in providers
override both methods or neither, so they behave as before.
ggivo
ggivo approved these changes Oct 19, 2026
View reviewed changes

@ggivo ggivo left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM. scanIteration, ftSearchIteration and ftAggregateIteration now iterate only the primaries, the same nodes all-shards commands are broadcast to, so on a cluster with replicas they no longer return duplicate keys (#4797).

I pushed two commits on top:

  • f416959 drops the release-notes entry.
  • 25ca6df changes the getPrimaryNodesConnectionMap() default to return getConnectionMap(). A custom provider that overrides only getConnectionMap() keeps its full map and no longer leaks a pooled connection.

I'll merge once CI is green

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ggivo
ggivo merged commit 7106a66 into redis:master Oct 20, 2026
20 of 22 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@ggivo

ggivo commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

@RaphaelFakhri
Thanks for the contribution! Merged now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 20, 2026
Iterate SCAN-like commands over primary nodes only #4802
Closed
scanIteration on a cluster with replicas returns every key more than once #4797
Closed
@ggivo ggivo mentioned this pull request Oct 28, 2026
[Redis 8.12] Support the BLESS command family #4773
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@ggivo ggivo ggivo approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug

Projects

None yet

Milestone

8.1.0

Development

Successfully merging this pull request may close these issues.

scanIteration on a cluster with replicas returns every key more than once

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@RaphaelFakhri @ggivo
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.