Visitar URL original
Backport #4745 to 8.0.x: Update failover.md and some javadoc by ggivo · Pull Request #4772 · redis/jedis · GitHub
Skip to content

Backport #4745 to 8.0.x: Update failover.md and some javadoc - #4772

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

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

Conversation

@ggivo

@ggivo ggivo commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Clean cherry-pick of 2861d3e1a (#4745) onto 8.x.

Rewrites docs/failover.md and updates the MultiDbConfig and HealthCheckStrategy Javadocs. Documentation only, no code changes.

Backport notes

Testing

  • Compiles on JDK 8; formatter:validate passes.
  • In-page anchors resolve; no other docs link into failover.md anchors.

Note

Low Risk
Documentation and Javadoc updates only; no production code behavior changes.

Overview
Major expansion and correction of docs/failover.md for MultiDbClient / MultiDbConfig: reorganized guide outline, documents the shorter database(endpoint, weight, clientConfig) builder overload, and clarifies that the circuit breaker uses a time-based sliding window (seconds) with both minimum failures and failure rate required to trip.

New or substantially added topics include failover/failback settings (defaults such as 2 min failback interval and 1 min grace period), initialization policies (7.3+), behavior when no healthy database exists (temporary vs permanent exceptions), health-check probe parameters and policies, updated fallback exception list (ConnectionFailoverException), DatabaseSwitchEvent / SwitchReason, manual setActiveDatabase vs forceActiveDatabase, and sharper runtime add/remove/query semantics.

Javadoc-only fixes in MultiDbConfig (builder example, sliding window in seconds, failback/grace default descriptions) and HealthCheckStrategy.Config builder (documented defaults 5000 ms interval and 500 ms between probes). No runtime logic changes.

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

* - update failover.md and some javadoc

* - fix javadoc

(cherry picked from commit 2861d3e)
@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:33:35.825366Z b057c29 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

  170 files   -    36    170 suites   - 36   32s ⏱️ - 8m 13s
3 287 tests  - 4 799  3 281 ✅  - 3 573  6 💤  - 1 226  0 ❌ ±0 
3 268 runs   - 4 826  3 262 ✅  - 3 592  6 💤  - 1 234  0 ❌ ±0 

Results for commit b057c29. ± Comparison against base commit af815c5.

♻️ This comment has been updated with latest results.

@ggivo
ggivo merged commit b7f5067 into 8.x Oct 5, 2026
15 of 16 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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: b057c295f2

ℹ️ 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".

Comment thread docs/failover.md
Comment on lines +608 to +610
```java
// Pin redis-east as the active database for the next 10 minutes
client.forceActiveDatabase(endpoint, Duration.ofMinutes(10).toMillis());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid passing a newly constructed endpoint to forceActiveDatabase

In the documented scenario, endpoint is a new HostAndPort equal to—but not identical to—the endpoint stored during configuration. MultiDbConnectionProvider.forceActiveDatabase() excludes the target using entry.getKey() != endpoint, so it also puts this target into the grace period; the subsequent validation then throws JedisValidationException instead of pinning it. Either fix that identity comparison or demonstrate obtaining the stored endpoint (for example from getDatabaseEndpoints()) before recommending this call.

Useful? React with 👍 / 👎.

Comment thread docs/failover.md
Comment on lines +259 to +263
MultiDbConfig config = MultiDbConfig.builder()
.database(east, 1.0f, clientConfig)
.database(west, 0.5f, clientConfig)
.initializationPolicy(InitializationPolicy.BuiltIn.ONE_AVAILABLE) // start as soon as one database is reachable
.build();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not promise ONE_AVAILABLE starts on the first reachable database

With multiple health-checked databases, ONE_AVAILABLE does not necessarily let build() return as soon as any database is reachable. waitForInitializationPolicy() sorts endpoints by weight and waits for each specific endpoint in that order, so a slow or unreachable high-weight endpoint blocks initialization even when a lower-weight endpoint has already reported healthy. This comment should not promise immediate startup unless the provider is changed to react to health results globally.

Useful? React with 👍 / 👎.

Comment thread docs/failover.md
- **Health Check Integration**: If health checks are configured, the new database will be monitored according to the configured health check strategy
- **Duplicate Prevention**: Attempting to add an endpoint that already exists will throw a `JedisValidationException`
- **Weight-Based Selection**: The new database participates in weight-based active database selection according to its configured weight
- **Weight-Based Selection**: The new database participates in weight-based active database selection according to its configured weight. Adding a database does not switch the active database by itself; if the new database has the highest weight, the next periodic failback check will switch to it

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Condition new-database switching on failback support

When failbackSupported(false) is configured, MultiDbConnectionProvider never schedules periodicFailbackCheck(), so adding a new highest-weight database will not switch to it on any later check; it remains inactive until a failover or manual switch occurs. Qualify this behavior with failback being enabled so users who disabled automatic failback do not wait for a switch that cannot happen.

Useful? React with 👍 / 👎.

Comment thread docs/failover.md
Comment on lines +422 to +423
If you already have a configured strategy instance, `healthCheckStrategy(HealthCheckStrategy)` wraps it in a supplier for you.
The same instance is then reused for every database that shares that `DatabaseConfig`, so make sure it is thread-safe.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prefer per-database health-check strategy instances

Thread safety alone does not make sharing this strategy instance safe. Every HealthCheckImpl treats its strategy as owned and calls strategy.close() when its database is removed or its client closes, so if the same DatabaseConfig is reused across clients—or the same instance is otherwise shared—closing one health check closes the resources still used by the others. Recommend a supplier that creates a distinct instance per database/client, or explicitly document the shared lifecycle hazard.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants