Visitar URL original
Backport #4765 to 8.0.x: Fail over to a recovered database when the active one is inoperable by ggivo · Pull Request #4774 · redis/jedis · GitHub
Skip to content

Backport #4765 to 8.0.x: Fail over to a recovered database when the active one is inoperable - #4774

Merged
ggivo merged 1 commit into
8.xfrom
topic/ggivo/backport/4765-8.0.x
Oct 5, 2026
Merged

ggivo merged 1 commit into
8.xfrom
topic/ggivo/backport/4765-8.0.x

Conversation

@ggivo

@ggivo ggivo commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Cherry-pick of c0c3c5da4 (#4765) onto 8.x.

After the active database became inoperable, MultiDbClient could stay on it even when a lower-weight database had recovered. Failover is now also attempted when a non-active database turns healthy, and when a command finds the active database unusable and another one usable.

Fixes #4764 for the 8.0.x line.

Backport notes

Testing

Run on JDK 8 against the local Docker Redis environment:

  • mcf unit and integration tests plus MultiDbProviderHealthStatusChangeTest: 305 tests, 0 failures.
  • With MultiDbConnectionProvider.java reverted to 8.x, 4 of the new or updated tests fail: userCommand_afterPermanent_onlySecondaryHealthyAgain_failsOverAutomatically_healthCheckDriven, userCommand_connectionExceptions_thenMultipleTemporary_thenPermanent_inOrder, postInit_assertOperability_candidateOperableAfterItsGrace_failsOverToIt, postInit_healthyEventWithoutFailoverTarget_countsAsFailoverAttempt.

Note

Medium Risk
Changes core MultiDb failover timing and active-DB selection on health events and failed commands; behavior shifts from “stay on broken active until manual failback” to automatic switch to any operable endpoint.

Overview
Fixes a case where MultiDbClient could remain pinned to an inoperable active database even after a lower-weight replica became usable again.

Health status changes: When a non-active database reports healthy, the provider now calls failoverIfActiveInoperable() if the active database is still unhealthy—not only when the active DB turns unhealthy. Failed failover attempts from health events still swallow exceptions so the health-check scheduler keeps running, with an updated warn log.

Command path: assertOperability() (used when a command cannot get a connection from the active DB) now attempts an immediate switch to any operable database instead of only throwing temporary/permanent “no healthy database” exceptions when a candidate exists. Switches use tryLock so in-flight failing commands do not block on an ongoing switch.

Docs clarify that recovery can happen automatically via health checks or the next command (any weight), and tweak SwitchReason.HEALTH_CHECK wording.

Tests are updated and expanded for automatic recovery after permanent outage, command-driven failover, grace-period timing, and forceActiveDatabase pinning behavior.

Reviewed by Cursor Bugbot for commit eae1b1d. Bugbot is set up for automated code reviews on this repo. Configure here.

…4765)

(cherry picked from commit c0c3c5d)

8.x adaptation: MultiDbProviderHealthStatusChangeTest mocks
TrackingConnectionPool (master gets this from #4668).
@ggivo ggivo added the bug label Oct 5, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

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-05T12:51:29.262487Z eae1b1d 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.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Test Results

  206 files  ±0    206 suites  ±0   8m 7s ⏱️ +8s
8 098 tests ±0  8 030 ✅ ±0  68 💤 ±0  0 ❌ ±0 
8 118 runs  ±0  8 050 ✅ ±0  68 💤 ±0  0 ❌ ±0 

Results for commit eae1b1d. ± Comparison against base commit b7f5067.

♻️ This comment has been updated with latest results.

@ggivo
ggivo merged commit 53fecac into 8.x Oct 5, 2026
15 of 18 checks passed
@ggivo
ggivo deleted the topic/ggivo/backport/4765-8.0.x branch October 14, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant