GeezerVison is showing github.com — Iterations on MultiDbClient return their pooled connections by ggivo · Pull Request #4800 · redis/jedis
Conversation
ggivo
commented
Oct 19, 2026
•
edited by cursor
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
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.
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]>
Five tests copied the same lookup of the active database's connection pool. MultiDbConnectionProviderHelper.activeConnectionPool replaces them; test code only.
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
|
|
|
|
|
@Override
|
|
|
public Map<?, Pool<Connection>> getPrimaryNodesConnectionMap() {
|
|
|
return getConnectionMap();
|
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.
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.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|