-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[automatic failover] Add dual thresholds (min num of failures + failure rate) capabililty to circuit breaker #4295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/automatic-failover-2
Are you sure you want to change the base?
Conversation
…t breaker executor - Map config to resilience4j via CircuitBreakerThresholdsAdapter - clean up/simplfy config: drop slow-call and window type - Add thresholdMinNumOfFailures; update some of the defaults - Update provider to use thresholds adapter - Update docs; align examples with new defaults - Add tests for 0% rate, edge thresholds
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
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 adds dual-threshold failover capability to Jedis multi-cluster circuit breaker functionality. The circuit breaker now requires both a minimum number of failures AND a failure rate threshold to be exceeded before triggering failover, providing more robust failover control.
Key changes:
- Introduces dual threshold logic requiring both minimum failures and failure rate criteria to be met
- Simplifies configuration by removing deprecated circuit breaker settings and updating defaults
- Adds new adapter class to handle threshold mapping to resilience4j configuration
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
File | Description |
---|---|
MultiClusterClientConfig.java |
Updated configuration with new dual threshold properties and simplified circuit breaker settings |
CircuitBreakerThresholdsAdapter.java |
New adapter class for mapping configuration to resilience4j circuit breaker settings |
CircuitBreakerCommandExecutor.java |
Added dual threshold checking logic before triggering failover |
CircuitBreakerFailoverBase.java |
Base class with shared threshold validation logic |
JedisFailoverThresholdsExceededException.java |
New exception type for threshold-based failover |
Various test files | Updated tests to remove deprecated configuration options and add threshold testing |
docs/failover.md |
Updated documentation with new defaults and simplified configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/main/java/redis/clients/jedis/mcf/CircuitBreakerThresholdsAdapter.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
private static int calculateMinTotalCalls(int failures, float rate) { | ||
int minCalls = (int) (failures * rate * 100); |
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 calculation appears incorrect. The formula failures * rate * 100
doesn't represent the minimum number of total calls needed. For example, if you need 3 failures at 50% rate, you'd need at least 6 total calls, but this formula gives 150. The correct formula should be (int) Math.ceil(failures / (rate / 100.0))
or (int) Math.ceil(failures * 100.0 / rate)
.
int minCalls = (int) (failures * rate * 100); | |
int minCalls = (int) Math.ceil(failures * 100.0 / rate); |
Copilot uses AI. Check for mistakes.
src/main/java/redis/clients/jedis/mcf/CircuitBreakerFailoverBase.java
Outdated
Show resolved
Hide resolved
src/main/java/redis/clients/jedis/mcf/CircuitBreakerFailoverConnectionProvider.java
Outdated
Show resolved
Hide resolved
src/main/java/redis/clients/jedis/mcf/CircuitBreakerCommandExecutor.java
Outdated
Show resolved
Hide resolved
…Adapter.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Add dual-threshold failover to Jedis multi-cluster: failover occurs only when both minimum failures and failure-rate thresholds are exceeded. Simplify configuration, adapt thresholds cleanly to resilience4j, and update docs/tests.
Key changes
Behavior
Migration
Validation