-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[automatic-failover] Integrate health checks with probing policies and retry logic (CAE-1685) #3541
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
[automatic-failover] Integrate health checks with probing policies and retry logic (CAE-1685) #3541
Conversation
Changes - add connection.getHealthStatus(RedisUri endpoint) - HEALTHY - returned for Databases without health checks configured - add test
Changes - add test to ensure health status changes from custom health checks are reflected
Changes - add test to ensure health status changes from custom health checks are reflected
…th check returns HEALTHY
- Should start health checks automatically when connection is created - Should stop health checks when connection is closed
- Update StatefulMultiDbConnectionIntegrationTests to account for added additional test server in MultiDbTestSupport - Junit4 @after replaced with JUnit5
- Update StatefulMultiDbConnectionIntegrationTests to account for added additional test server in MultiDbTestSupport - Junit4 @after replaced with JUnit5
atakavci
left a comment
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.
some of them are nothing more than questions.
one to take more seriously is the order with registering listeners.
i ll try go another round with clear mind.
src/main/java/io/lettuce/core/failover/api/BaseRedisMultiDbConnection.java
Outdated
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java
Outdated
Show resolved
Hide resolved
- covered with unit tests
atakavci
left a comment
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
[automatic-failover] Integrate health checks with probing policies and retry logic
Summary
This PR integrates health check functionality into the automatic failover feature, providing endpoint health monitoring with configurable probing policies and retry logic. The implementation is ported from Jedis and adapted to Lettuce's architecture.
Key Features
Health Check System
HealthCheckImpl: Core implementation with periodic health status monitoringHealthCheckStrategy: Configurable strategy interface for health check behaviordoHealthCheck(RedisURI)HealthStatusManager: Centralized management of health checks across multiple endpointsProbing Policies
ANY_SUCCESS: Returns HEALTHY if any probe succeedsALL_SUCCESS: Returns HEALTHY only if all probes succeedMAJORITY_SUCCESS: Returns HEALTHY if majority of probes succeedRetry Logic
numProbesfor multiple health check attemptsMultiDbClient Integration
HEALTHYby defaultImplementation Details
Architecture:
ExecutorService(cached thread pool) for health check executionScheduledExecutorServicefor periodic schedulingLifecycle Management:
UNKNOWNstatusHEALTHY/UNHEALTHYafter first check completesTesting
Unit Tests
HealthCheckCollectionUnitTests- Collection managementHealthCheckImplUnitTests- Core functionalityHealthCheckImplRetryLogicUnitTests- Health Check Retry logicHealthCheckImplProbingPolicyUnitTests- Probing policiesTestHealthCheckStrategy- Shared test helper, with controllable health statuses per endpointIntegration Tests
HealthCheckIntegrationTestFiles Changed
Main Implementation:
src/main/java/io/lettuce/core/failover/health/- Health check package (10 files)src/main/java/io/lettuce/core/failover/MultiDbClientImpl.java- Integrationsrc/main/java/io/lettuce/core/failover/StatefulRedisMultiDbConnectionImpl.java- Connection lifecycleTests:
src/test/java/io/lettuce/core/failover/health/src/test/java/io/lettuce/core/failover/HealthCheckIntegrationTest.java- Integration testsRelated Issues
Breaking Changes
None - This is a new feature addition.
Follow-up Items for Discussion
Static
ExecutorServicevsEventExecutorGroupExecutorService(unbounded cached thread pool) for health check executionEventExecutorGroupfromClientResourcesfor better lifecycle management and bounded thread poolfuture.get()which requires dedicated threads;EventExecutorGroupis shared across componentsStatusTracker.waitForHealthStatus()Blocking BehaviorconnectAsync()is introduced to provide non-blocking alternativeCompletableFuture<HealthStatus> awaitHealthStatus()methodHealthCheckImpl.stop()Blocking Shutdownscheduler.awaitTermination()CompletableFuture<Void> closeAsync()for non-blocking shutdown