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 — Iterations on MultiDbClient return their pooled connections by ggivo · Pull Request #4800 · redis/jedis

Conversation

@ggivo

@ggivo ggivo 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
Collaborator

MultiDbConnectionProvider overrode getConnectionMap() but not getPrimaryNodesConnectionMap(), so the interface default borrowed a pooled connection that the iteration code treats as caller-owned and never returns. Each ftAggregateIterator call on a MultiDbClient leaked one connection until the pool was exhausted (reproducer in #4799). The provider now returns the active database's pool from both methods.

MultiDbScanIterationIT and MultiDbAggregateIterationIT assert the pool has no active connections after each iteration. On master only ftAggregateIterator leaks; the scanIteration and ftAggregateIteration cases guard #4798, which moves JedisCommandIterationBase to the primaries map.

The second commit moves five copies of the active-pool lookup in MultiDb tests into MultiDbConnectionProviderHelper.activeConnectionPool (test code only).

Extracted from #4798 so it can merge and be backported on its own; the fix is @RaphaelFakhri's.

Fixes #4799


Note

Medium Risk
Changes connection acquisition for iteration paths on MultiDbClient; low surface area but affects pool lifecycle for RediSearch aggregate and scan APIs.

Overview
Fixes a connection pool leak on MultiDbClient when using cursor-style APIs such as ftAggregateIterator / ftAggregateIteration (and guards similar behavior for scanIteration).

MultiDbConnectionProvider already exposed the active database pool via getConnectionMap(), but getPrimaryNodesConnectionMap() still used the ConnectionProvider default that borrows a pooled connection. Iteration code treats that map as pool-backed and does not return a bare Connection, so each aggregate iteration could leave getNumActive() stuck until the pool exhausted (#4799).

The provider now overrides getPrimaryNodesConnectionMap() to delegate to getConnectionMap(), so primaries resolve to the same active-database pool.

Tests: new MultiDbScanIterationIT and MultiDbAggregateIterationIT assert zero active connections after iteration; existing MultiDb ITs share MultiDbConnectionProviderHelper.activeConnectionPool instead of duplicating pool lookup.

Reviewed by Cursor Bugbot for commit 57c8e80. 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
ggivo and others added 2 commits October 19, 2026 15:51
@ggivo @RaphaelFakhri
Return pooled connections from iterations on MultiDbClient
5905488
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]>
@ggivo
Share the MultiDbClient active-pool test helper
57c8e80
Five tests copied the same lookup of the active database's connection pool. MultiDbConnectionProviderHelper.activeConnectionPool replaces them; test code only.
@ggivo ggivo added area:multidb bug labels Oct 19, 2026
@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-19T13:06:17.038795Z 57c8e80 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.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions

github-actions Bot commented Oct 19, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Test Results

  208 files  + 2    208 suites  +2   8m 53s ⏱️ +36s
8 126 tests  -  9  6 894 ✅  - 1 173  1 232 💤 +1 164  0 ❌ ±0 
8 134 runs   - 21  6 894 ✅  - 1 193  1 240 💤 +1 172  0 ❌ ±0 

Results for commit 57c8e80. ± Comparison against base commit ddee9d5.

This pull request removes 14 and adds 5 tests. Note that renamed tests count towards both.
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[1] ‑ testScorer(Scorer, double, double)[1][1]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[1] ‑ testScorer(Scorer, double, double)[1][2]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[1] ‑ testScorer(Scorer, double, double)[1][3]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[1] ‑ testScorer(Scorer, double, double)[1][4]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[1] ‑ testScorer(Scorer, double, double)[1][5]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[1] ‑ testScorer(Scorer, double, double)[1][6]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[1] ‑ testScorer(Scorer, double, double)[1][7]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[2] ‑ testScorer(Scorer, double, double)[2][1]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[2] ‑ testScorer(Scorer, double, double)[2][2]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest[2] ‑ testScorer(Scorer, double, double)[2][3]
…
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest ‑ testScorer(Scorer, double, double)[1]
redis.clients.jedis.commands.unified.search.FTHybridCommandsTestBase$SupportedScorersTest ‑ testScorer(Scorer, double, double)[2]
redis.clients.jedis.mcf.MultiDbAggregateIterationIT ‑ ftAggregateIteration_releasesConnection
redis.clients.jedis.mcf.MultiDbAggregateIterationIT ‑ ftAggregateIterator_releasesConnection
redis.clients.jedis.mcf.MultiDbScanIterationIT ‑ scanIteration_releasesConnection
This pull request skips 1162 tests.
redis.clients.jedis.UnboundRedisClusterClientTest ‑ testAskResponseWithHimportSet
redis.clients.jedis.commands.commandobjects.CommandObjectsArrayCommandsTest[1] ‑ testArcountMissingKey()[1]
redis.clients.jedis.commands.commandobjects.CommandObjectsArrayCommandsTest[1] ‑ testArcountMissingKeyBinary()[1]
redis.clients.jedis.commands.commandobjects.CommandObjectsArrayCommandsTest[1] ‑ testArdel()[1]
redis.clients.jedis.commands.commandobjects.CommandObjectsArrayCommandsTest[1] ‑ testArdelBinary()[1]
redis.clients.jedis.commands.commandobjects.CommandObjectsArrayCommandsTest[1] ‑ testArdelrange()[1]
redis.clients.jedis.commands.commandobjects.CommandObjectsArrayCommandsTest[1] ‑ testArdelrangeBinary()[1]
redis.clients.jedis.commands.commandobjects.CommandObjectsArrayCommandsTest[1] ‑ testArget()[1]
redis.clients.jedis.commands.commandobjects.CommandObjectsArrayCommandsTest[1] ‑ testArgetBinary()[1]
redis.clients.jedis.commands.commandobjects.CommandObjectsArrayCommandsTest[1] ‑ testArgetrange()[1]
…

♻️ This comment has been updated with latest results.

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: 57c8e80576

ℹ️ 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/mcf/MultiDbConnectionProvider.java

@Override
public Map<?, Pool<Connection>> getPrimaryNodesConnectionMap() {
return getConnectionMap();

@chatgpt-codex-connector chatgpt-codex-connector Bot Oct 19, 2026

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.

P2 Badge Reopen the active pool before returning it

With fast failover enabled, switchToHealthyDatabase(..., false) can reactivate a database whose pool was previously closed by forceDisconnect(). This override delegates to getConnectionMap(), which reads activeDatabase.connectionPool directly, so ftAggregateIterator then attempts to borrow from a closed pool and fails until an unrelated ordinary command calls Database.getConnection() to recreate it; the previous default implementation performed that recreation itself. Return an open pool through a database accessor rather than exposing the field directly.

Useful? React with 👍 / 👎.

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/mcf/MultiDbConnectionProvider.java Resolved

Uh oh!

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

@ggivo
ggivo merged commit 4bc72cc into master Oct 19, 2026
17 of 18 checks passed

Uh oh!

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

@ggivo
ggivo deleted the topic/ggivo/multidb-iteration-connection-leak branch October 19, 2026 13:12
@ggivo ggivo mentioned this pull request Oct 19, 2026
Scan only primary nodes in scanIteration on cluster #4798
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

Uh oh!

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

Assignees

No one assigned

Labels

area:multidb bug

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Iterations on MultiDbClient leak a pooled connection

Uh oh!

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

1 participant

@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.