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 — Fix connection leak in scanIteration with JedisSentineled #4323 by ggivo · Pull Request #4328 · redis/jedis

Conversation

@ggivo

@ggivo ggivo commented Oct 13, 2025

Copy link
Copy Markdown
Collaborator

Problem

When using scanIteration() with JedisSentineled, connections are leaked from the pool and never returned.

SentineledConnectionProvider uses the default ConnectionProvider.getConnectionMap() implementation, which allocates a raw Connection from the pool. JedisCommandIterationBase uses this connection directly (line 68-69) without returning it to the pool.

Solution

Override getConnectionMap() and getPrimaryNodesConnectionMap() in SentineledConnectionProvider to return the pool itself, consistent with PooledConnectionProvider:

@Override
public Map<?, Pool<Connection>> getConnectionMap() {
  return Collections.singletonMap(currentMaster, pool); 
}
 
@Override
public Map<?, Pool<Connection>> getPrimaryNodesConnectionMap() {
   return Collections.singletonMap(currentMaster, pool);
}

This allows JedisCommandIterationBase to properly manage connections using try-with-resources (lines 71-73).

Note on volatile pool: The iteration captures the pool reference at construction time. Connections from the old pool remain valid even if failover occurs during iteration.

Note on returning a Pool<Connection> by getConnectionMap vs Connection to:

  • JedisCommandIterationBase already handles both Connection and Pool types (lines 68-76)
  • getConnectionMap() is only used internally by iteration classes
  • This change aligns SentineledConnectionProvider with PooledConnectionProvider's existing behavior
  • Previous behavior would cause connections to be exhausted using multilpe times scan operaions

Fixes #4323

Sorry, something went wrong.

Uh oh!

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

All reactions
ggivo added 2 commits October 10, 2025 13:06
@ggivo
docs: document required optional dependency resilience4j-all when u…
ce55829
…sing failover client
@ggivo
Fix connection leak in scanIteration with JedisSentineled
322d612
Override getConnectionMap() in SentineledConnectionProvider to return
the pool instead of a raw connection. This prevents connection leaks
when using scanIteration() with JedisSentineled.

Fixes #4323
@github-actions

github-actions Bot commented Oct 13, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Test Results

   280 files  +  1    280 suites  +1   11m 29s ⏱️ -14s
10 188 tests +125  9 123 ✅  - 895  1 065 💤 +1 020  0 ❌ ±0 
 2 703 runs  +  2  2 703 ✅ +  2      0 💤 ±    0  0 ❌ ±0 

Results for commit d296279. ± Comparison against base commit 1d8d075.

This pull request skips 1011 tests.
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[1] ‑ testHgetdel
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[1] ‑ testHgetdelBinary
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[1] ‑ testHgetex
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[1] ‑ testHgetexBinary
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[1] ‑ testHsetex
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[1] ‑ testHsetexBinary
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[2] ‑ testHgetdel
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[2] ‑ testHgetdelBinary
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[2] ‑ testHgetex
redis.clients.jedis.commands.commandobjects.CommandObjectsHashCommandsTest[2] ‑ testHgetexBinary
…

♻️ 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.

@ggivo
ggivo marked this pull request as ready for review October 14, 2025 06:45
@ggivo
Merge branch 'master' into ggivo/4323-sentineled-scan-leak
8b76086
@ggivo
ggivo requested a review from Copilot October 14, 2025 06:46
Copilot AI reviewed Oct 14, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Pull Request Overview

This PR fixes a connection leak issue in SentineledConnectionProvider when using scanIteration() operations. The problem occurred because connections were allocated from the pool but never returned.

  • Overrides getConnectionMap() and getPrimaryNodesConnectionMap() to return the pool instead of raw connections
  • Adds comprehensive test coverage to verify the connection leak fix
  • Includes integration tests to ensure compatibility with sentinel-based operations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
SentineledConnectionProvider.java Implements pool-based connection maps to prevent leaks
SentineledConnectionProviderTest.java Adds unit tests verifying no connection leaks occur
SentinelAllKindOfValuesCommandsIT.java Adds integration test class for sentinel command operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread src/test/java/redis/clients/jedis/SentineledConnectionProviderTest.java Resolved

Uh oh!

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

Comment thread src/test/java/redis/clients/jedis/SentineledConnectionProviderTest.java Resolved

Uh oh!

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

Comment thread src/test/java/redis/clients/jedis/SentineledConnectionProviderTest.java Resolved

Uh oh!

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

@ggivo
ggivo requested review from atakavci and uglide October 14, 2025 06:47
@ggivo
Merge branch 'master' into ggivo/4323-sentineled-scan-leak
d296279
jit-ci[bot]
jit-ci Bot reviewed Oct 20, 2025
View reviewed changes

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

❌ The following Jit checks failed to run:

  • static-code-analysis-semgrep-pro

#jit_bypass_commit in this PR to bypass, Jit Admin privileges required.

More info in the Jit platform.

Sorry, something went wrong.

Uh oh!

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

All reactions
atakavci
atakavci approved these changes Oct 21, 2025
View reviewed changes

@atakavci atakavci left a comment

Copy link
Copy Markdown
Contributor

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

Sorry, something went wrong.

Uh oh!

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

All reactions
@ggivo ggivo self-assigned this Oct 21, 2025
@ggivo ggivo added the bug label Oct 21, 2025
@ggivo ggivo added this to the 7.0.1 milestone Oct 21, 2025
@ggivo
ggivo merged commit 4ddd7f4 into master Oct 21, 2025
@ggivo
ggivo deleted the ggivo/4323-sentineled-scan-leak branch October 21, 2025 11:44
@ggivo ggivo mentioned this pull request Nov 6, 2025
[Backport 7.0.x] Fix ScanIteration (JedisCommandIterationBase) connection leak with JedisSentinel #4351
Closed
ggivo added a commit that referenced this pull request Nov 6, 2025
@ggivo
Fix connection leak in scanIteration with JedisSentineled #4323 (#4328)
47473c8
* docs: document required optional dependency `resilience4j-all` when using failover client

* Fix connection leak in scanIteration with JedisSentineled

Override getConnectionMap() in SentineledConnectionProvider to return
the pool instead of a raw connection. This prevents connection leaks
when using scanIteration() with JedisSentineled.

Fixes #4323

(cherry picked from commit 4ddd7f4)
@ggivo ggivo mentioned this pull request Nov 6, 2025
Fix connection leak in scanIteration with JedisSentineled #4323 (#4328) #4352
Merged
ggivo added a commit that referenced this pull request Nov 6, 2025
@ggivo
Fix connection leak in scanIteration with JedisSentineled #4323 (#4328)…
5902472
… (#4352)

* docs: document required optional dependency `resilience4j-all` when using failover client

* Fix connection leak in scanIteration with JedisSentineled

Override getConnectionMap() in SentineledConnectionProvider to return
the pool instead of a raw connection. This prevents connection leaks
when using scanIteration() with JedisSentineled.

Fixes #4323

(cherry picked from commit 4ddd7f4)
@ggivo ggivo removed this from the 7.0.1 milestone Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@atakavci atakavci atakavci approved these changes
@uglide uglide Awaiting requested review from uglide
+1 more reviewer
@jit-ci jit-ci[bot] jit-ci[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

@ggivo ggivo

Labels

bug

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

ScanIteration (JedisCommandIterationBase) connection leak with JedisSentineled

Uh oh!

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

3 participants

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