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 — Unregister the MultiDb health status listener when a database is removed by kdelay · Pull Request #4791 · redis/jedis

Conversation

@kdelay

@kdelay kdelay commented Oct 16, 2026 •
edited by cursor Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

MultiDbConnectionProvider.remove unregisters the health listener with a new this::onHealthStatusChange, which never equals the one addDatabaseInternal registered (each method reference is a new object), so the listener stays. Same cause as #4749.

Listeners left for the endpoint in HealthStatusManager.endpointListeners: 1 after remove, 2 after re-adding it, 3 after another remove/add. Each health event then runs onHealthStatusChange once per copy.

The fix keeps one instance for both calls, like ConnectionPool.postAuthenticationHook.

The new test fails on master (expected: <0> but was: <1>) and passes with the fix. mvn test on JDK 17: 3490 tests, 0 failures; the 1 error, TokenBasedAuthenticationUnitTests, also fails on master (500 ms await).


Note

Medium Risk
Touches multi-database failover health callbacks; incorrect unregister could duplicate failover handling, but the change is a small identity fix with targeted test coverage.

Overview
Fixes a listener leak when dynamically removing a database from MultiDbConnectionProvider. remove called unregisterListener with a new this::onHealthStatusChange method reference, which never equals the listener registered in addDatabaseInternal, so the callback stayed attached and could stack on remove/add cycles (same class of bug as #4749).

The provider now keeps one healthStatusListener instance and uses it for both register and unregister. HealthStatusManager exposes a test-only getListeners(Endpoint) snapshot, plus getHealthStatusManager() on the provider. A unit test asserts the endpoint has zero listeners after remove and exactly one after re-add.

Reviewed by Cursor Bugbot for commit ed77c35. 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
@kdelay
Unregister the MultiDb health status listener when a database is removed
d4b84fc
remove() passed a fresh this::onHealthStatusChange to unregisterListener,
which never matches the instance registered by addDatabaseInternal, so the
listener stayed and accumulated across remove/add cycles. Keep one instance
for both calls, as ConnectionPool does for its post-authentication hook.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-19T10:28:51.801484Z ed77c35 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 16, 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: d4b84fce4d

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

Uh oh!

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

@ggivo ggivo added waiting-for-feedback We need additional information before we can continue status: waiting-for-review and removed waiting-for-feedback We need additional information before we can continue labels Oct 16, 2026
ggivo added 2 commits October 19, 2026 12:12
@ggivo
Merge branch 'master' into fix/multidb-health-listener-unregister
f2c78a9
@ggivo
Move the health listener test next to the other add/remove tests
854100a
MultiDbConnectionProviderDynamicEndpointUnitTest already covers add and
remove with the same mocked pool setup, so the case does not need its
own class. Package-private @VisibleForTesting accessors on the provider
and HealthStatusManager replace the reflection on their private fields.
@ggivo

ggivo commented Oct 19, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Collaborator

Thanks for the contribution!

Confirmed: this::onHealthStatusChange creates a new instance on each evaluation, so the unregister in remove() never matched. Keeping one instance fixes it and matches #4749.

Pushed 854100a on top of your branch: the test moved into MultiDbConnectionProviderDynamicEndpointUnitTest, which already covers add/remove with the same setup, and package-private @VisibleForTesting accessors (MultiDbConnectionProvider.getHealthStatusManager(), HealthStatusManager.getListeners(Endpoint)) replace the reflection on private fields. The test still fails without the fix.

All reactions

Sorry, something went wrong.

Uh oh!

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

@ggivo ggivo added bug and removed status: waiting-for-review labels Oct 19, 2026
@ggivo ggivo added this to the 8.1.0 milestone Oct 19, 2026
@ggivo
Merge branch 'master' into fix/multidb-health-listener-unregister
ed77c35
@ggivo ggivo added the area:multidb label Oct 19, 2026
@ggivo
ggivo merged commit ddee9d5 into redis:master Oct 19, 2026
14 of 15 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

@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

8.1.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

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