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 'MultiDbClient' compatibility with client-side cache-enabled configuration by atakavci · Pull Request #4568 · redis/jedis

Conversation

@atakavci

@atakavci atakavci commented Jun 22, 2026 •
edited by cursor Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Summary

This PR fixes client-side caching support with MultiDbConnectionProvider by threading the Cache instance through the connection provider and pool layers.

Changes

Core Implementation

  • MultiDbConnectionProvider: Added new constructor accepting Cache parameter and updated pool creation to pass cache to TrackingConnectionPool
  • TrackingConnectionPool: Extended builder pattern to accept and propagate Cache through connection factory and pool recreation
  • MultiDbClientBuilder: Updated to pass cache instance when constructing MultiDbConnectionProvider

Key Features

  • Cache instance is shared across all database connections in a multi-database setup
  • Cache is preserved during database switches and pool recreations
  • Backward compatibility maintained with no-arg constructor for non-cached scenarios

Testing

Added comprehensive test coverage including:

  • Basic cache functionality with MultiDbClient
  • Cache preservation during pool recreation (fast failover scenario)
  • Cache behavior with dynamic database additions
  • Cache persistence across database switches

Test Improvements

  • Disabled health checks in most tests for faster execution
  • Updated test assertions to work with health check disabled mode
  • Added proper health check configuration for tests that need it

Files Changed

  • MultiDbConnectionProvider.java - Added cache support with dual constructors
  • TrackingConnectionPool.java - Enhanced builder to accept and propagate cache
  • MultiDbClientBuilder.java - Updated provider instantiation to include cache
  • MultiDbClientTest.java - Added 4 new cache-related tests and improved existing tests

Note

Medium Risk
Changes affect multi-database connection pooling and cache invalidation on failover/switch; incorrect cache sharing could serve stale data across endpoints, though behavior is heavily tested.

Overview
MultiDbClient can now use client-side caching (CSC) by passing the builder’s Cache into MultiDbConnectionProvider, through TrackingConnectionPool / ConnectionFactory, so pooled connections become CacheConnection when a cache is configured. The same cache instance is reused when pools are rebuilt via TrackingConnectionPool.from() (e.g. after fast failover closes the old pool).

MultiDbClientBuilder constructs the provider with cache; the original single-arg provider constructor remains for non-cached setups.

Tests add RESP2/RESP3 parameterization for MultiDbClientTest, CSC integration scenarios (switches, dynamic DB add, pool recreation), RedisMultiDbClientSideCacheTest, mock-server MultiDbCSCTest (flush on fast-failover switch vs no flush otherwise), and coverage for mid-transaction active-database switches on MultiDbTransaction.

Reviewed by Cursor Bugbot for commit 6fc5518. 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
atakavci added 2 commits June 21, 2026 10:06
@atakavci
- fix multidb instance does not regard cache configuration
5882774
@atakavci
- improve test coverage for cache enabled mutlidbclient
fb84b04
@atakavci
atakavci requested review from Copilot and ggivo June 22, 2026 07:27
@atakavci atakavci self-assigned this Jun 22, 2026
@atakavci atakavci added the bug label Jun 22, 2026
Copilot started reviewing on behalf of atakavci June 22, 2026 07:27
View session
Copilot AI reviewed Jun 22, 2026
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 client-side caching (CSC) for MultiDbClient by propagating a shared Cache instance from MultiDbClientBuilder into MultiDbConnectionProvider, then down into TrackingConnectionPool so cache-enabled connections continue to work across database switches and pool recreation.

Changes:

  • Thread Cache from MultiDbClientBuilder → MultiDbConnectionProvider → TrackingConnectionPool/ConnectionFactory (and preserve it on TrackingConnectionPool.from() pool recreation).
  • Add cache-focused integration tests for multi-db CSC behavior (including fast-failover/pool recreation and dynamic database addition).
  • Speed up existing integration tests by disabling health checks for most scenarios.

Reviewed changes

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

File Description
src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java Adds cache-aware constructor and passes Cache into pool creation.
src/main/java/redis/clients/jedis/mcf/TrackingConnectionPool.java Extends builder to accept Cache and ensures recreated pools keep the same cache.
src/main/java/redis/clients/jedis/builders/MultiDbClientBuilder.java Passes builder cache into MultiDbConnectionProvider.
src/test/java/redis/clients/jedis/MultiDbClientTest.java Adds CSC integration coverage and updates tests to avoid health-check waits in most cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. 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/MultiDbClientTest.java Resolved

Uh oh!

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

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

Uh oh!

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

Comment thread src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java Resolved

Uh oh!

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

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

Uh oh!

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

atakavci added 5 commits June 22, 2026 10:52
@atakavci
-improve test reliability
bfcb8ef
- format
@atakavci
- make multidbclienttest against both RESP2 and RESP3
47ec82d
@atakavci
Merge branch 'master' into ali/multidbwithcache
bb08f1e
@atakavci
- version checks for CSC enabled tests
71cf5cc
@atakavci
Merge branch 'master' into ali/multidbwithcache
cc0c082
cursor[bot]
cursor Bot reviewed Jun 29, 2026
View reviewed changes
Comment thread src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java Resolved

Uh oh!

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

atakavci added 5 commits July 1, 2026 09:52
@atakavci
Merge branch 'master' into ali/multidbwithcache
83ac3c3
@atakavci
- improve test coverage for CSC enabled multidb client
2ab508c
- add tests to assert midtransaction failure in multidbtransaction
@atakavci
- remove cache from test instance
badb7ee
@atakavci
- include new files in format
6e42ce5
@atakavci
- register version checker for csc support
6fc5518
cursor[bot]
cursor Bot reviewed Jul 1, 2026
View reviewed changes

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 6fc5518. Configure here.

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/builders/MultiDbClientBuilder.java

// Create the multi-database connection provider
MultiDbConnectionProvider provider = new MultiDbConnectionProvider(multiDbConfig);
MultiDbConnectionProvider provider = new MultiDbConnectionProvider(multiDbConfig, cache);

@cursor cursor Bot Jul 1, 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.

Custom provider hides client cache

Medium Severity

If MultiDbClient is built with a preconfigured MultiDbConnectionProvider that was constructed with a Cache, connections use client-side caching but UnifiedJedis.getCache() stays null unless the same Cache is also passed on the builder.

Additional Locations (1)
  • src/test/java/redis/clients/jedis/mcf/MultiDbCSCTest.java#L53-L55
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6fc5518. Configure here.

Sorry, something went wrong.

Uh oh!

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

All reactions
ggivo
ggivo approved these changes Jul 1, 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

Sorry, something went wrong.

Uh oh!

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

All reactions
@atakavci atakavci mentioned this pull request Jul 1, 2026
Cache instance would diverge or lost when provider or executors are customized with client builders. #4588
Open
@atakavci
atakavci merged commit 4ac22d5 into redis:master Jul 2, 2026
18 checks passed

Uh oh!

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

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
@ggivo ggivo ggivo approved these changes
+1 more reviewer
@cursor cursor[bot] cursor[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

@atakavci atakavci

Labels

bug

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

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