Skip to content

[automatic failover] Implement async creation support for StatefulRedisMultiDbConnection on MultiDbClient#3600

Merged
atakavci merged 19 commits intoredis:feature/automatic-failover-1from
atakavci:failover/asyncConnect
Jan 14, 2026
Merged

[automatic failover] Implement async creation support for StatefulRedisMultiDbConnection on MultiDbClient#3600
atakavci merged 19 commits intoredis:feature/automatic-failover-1from
atakavci:failover/asyncConnect

Conversation

@atakavci
Copy link
Copy Markdown
Collaborator

@atakavci atakavci commented Jan 2, 2026

Add Asynchronous Connection API for Multi-Database Client

Overview

This PR introduces a new asynchronous connection API (connectAsync) for the MultiDbClient, enabling non-blocking connection establishment to multiple Redis databases with parallel health checking and intelligent database selection.

Motivation

The existing connect() method is synchronous and blocks until all database connections are established and health checks complete. This can cause significant delays in applications that need to establish connections to multiple Redis databases, especially in scenarios where:

  • Some databases may be slow to respond
  • Network latency varies across databases
  • Applications need to remain responsive during connection establishment
  • Microservices need fast startup times

Changes

1. New Asynchronous Connection API

Added MultiDbClient.connectAsync(RedisCodec<K, V> codec)

  • Returns MultiDbConnectionFuture<K, V> (extends BaseConnectionFuture)
  • Non-blocking connection establishment
  • Parallel connection attempts to all configured databases
  • Asynchronous health check waiting
  • Partial success support (succeeds if at least one database is healthy)
  • Deadlock prevention: All callbacks execute on a separate thread pool, not on Netty event loop threads

2. New MultiDbAsyncConnectionBuilder Class

Created a new package-private class that encapsulates all async connection orchestration logic:

Key Methods:

  • connectAsync() - Main entry point for async connection creation
  • createRedisDatabaseAsync() - Creates individual database connections asynchronously
  • handleDatabaseFutures() - Orchestrates collection and health checking
  • collectDatabasesWithEstablishedConnections() - Implements partial success pattern
  • collectHealthStatuses() - Waits asynchronously for all health statuses

Features:

  • ✅ Parallel connection establishment to all databases
  • ✅ Asynchronous health check waiting (no blocking)
  • ✅ Partial success pattern (at least one healthy database required)
  • ✅ Proper resource cleanup on failures
  • ✅ Weight-based database selection
  • ✅ Comprehensive error handling with suppressed exceptions

3. Enhanced StatusTracker with Async Support

Added waitForHealthStatusAsync(RedisURI endpoint)

  • Returns CompletableFuture<HealthStatus>
  • Event-driven approach using HealthStatusListener
  • Automatic timeout handling using ClientResources.eventExecutorGroup()
  • Proper listener cleanup with AtomicBoolean to prevent race conditions
  • Race condition protection with double-check pattern
  • Scheduler cleanup on future completion

Updated Constructor:

  • Now accepts ClientResources parameter for accessing the event executor
  • Updated instantiation in MultiDbClientImpl to pass ClientResources

4. Refactored MultiDbClientImpl

Changes:

  • Extracted multi-db connection creation to createMultiDbConnection() method
  • Updated StatusTracker instantiation to include ClientResources in both connect() and connectPubSub() methods
  • Implemented connectAsync() using MultiDbAsyncConnectionBuilder
  • Maintained backward compatibility with existing connect() method
  • Added comprehensive JavaDoc for the synchronous connect() method explaining blocking behavior

5. New BaseConnectionFuture Class

Created a new abstract base class for connection futures that provides protection against event loop deadlocks:

Purpose:

  • Ensures all callbacks (thenApply, thenAccept, etc.) execute on a separate thread pool
  • Prevents deadlocks when users call blocking sync operations inside callbacks
  • Implements both CompletionStage<T> and Future<T> interfaces

Key Features:

  • All non-async methods (thenApply, thenAccept, etc.) are forced to execute asynchronously
  • Uses ForkJoinPool.commonPool() as default executor
  • Allows custom executor via constructor
  • Abstract wrap() method for subclasses to wrap new futures

Example Problem Solved:

// DANGEROUS with plain CompletableFuture - can deadlock!
future.thenApply(conn -> conn.sync().ping());

// SAFE with BaseConnectionFuture - always runs on separate thread
future.thenApply(conn -> conn.sync().ping());

6. New MultiDbConnectionFuture Class

Created a specialized connection future for multi-database connections:

Extends: BaseConnectionFuture<StatefulRedisMultiDbConnection<K, V>>

Key Methods:

  • from(CompletableFuture<...> future) - Static factory method
  • from(CompletableFuture<...> future, Executor executor) - Static factory with custom executor
  • wrap(CompletableFuture<U> future) - Implementation of abstract method from base class

Features:

  • Type-safe wrapper for multi-db connection futures
  • Inherits all deadlock prevention from BaseConnectionFuture
  • Used as return type for MultiDbClient.connectAsync()

7. Minor Visibility Change

RedisDatabaseImpl.getConnection():

  • Changed visibility from public to package-private
  • Only used internally within the failover package

8. Comprehensive Test Coverage

Unit Tests (MultiDbAsyncConnectionBuilderUnitTests):

  • 13 unit tests covering all package-private methods
  • Uses Mockito for mocking (no Redis required)
  • Tests partial success, edge cases, and error scenarios
  • ✅ All tests passing

Integration Tests:

  • Enhanced existing integration test files with proper test tag constants
  • Tests real Redis connections
  • Covers partial failures, null codec, multiple connections, different codecs
  • Tests future composition and exception handling

9. Updated Test Tags

Standardized test tags across all test files to use TestTags.UNIT_TEST and TestTags.INTEGRATION_TEST constants instead of string literals:

  • CircuitBreakerMetricsIntegrationTests
  • DatabaseCommandTrackerUnitTests
  • DatabaseEndpointCallbackTests
  • DatabasePubSubEndpointTrackerTests
  • HealthCheckIntegrationTests
  • MultiDbAsyncConnectionBuilderUnitTests (new)

Technical Details

Connection Flow

connectAsync(codec)
    ↓
Create HealthStatusManager
    ↓
Create MultiDbAsyncConnectionBuilder
    ↓
For each database config:
    - createRedisDatabaseAsync() [parallel]
    ↓
Wait for all connections (CompletableFuture.allOf)
    ↓
collectDatabasesWithEstablishedConnections()
    - Collect successful connections
    - Log failures
    - Throw if ALL failed
    ↓
collectHealthStatuses() [async]
    - Wait for health status of each database
    - Use StatusTracker.waitForHealthStatusAsync()
    - Select most weighted healthy database
    ↓
createMultiDbConnection()
    - Create StatefulRedisMultiDbConnectionImpl
    ↓
Wrap in MultiDbConnectionFuture
    - Provides deadlock prevention
    - Uses eventExecutorGroup as default executor
    ↓
Return MultiDbConnectionFuture

Partial Success Pattern

The implementation supports partial success:

  • If all databases fail to connect → throws RedisConnectionException with all failures as suppressed exceptions
  • If at least one database connects successfully → proceeds with health checks
  • If all databases are unhealthy → throws RedisConnectionException
  • If at least one database is healthy → succeeds with healthy databases only

Async Health Check Implementation

The StatusTracker.waitForHealthStatusAsync() method uses an event-driven approach:

  1. Checks if status is already determined (fast path)
  2. Registers a temporary HealthStatusListener for the endpoint
  3. Double-checks status after registration (race condition protection)
  4. Uses ClientResources.eventExecutorGroup() to schedule timeout
  5. Cleans up listener using AtomicBoolean to prevent double removal
  6. Ensures scheduler shutdown on timeout

Deadlock Prevention

The MultiDbConnectionFuture (via BaseConnectionFuture) solves a critical problem with async connection handling:

Problem: When using plain CompletableFuture, callbacks can execute on Netty event loop threads. If a callback calls a blocking sync operation (like conn.sync().ping()), it blocks the event loop thread, causing a deadlock.

Solution: BaseConnectionFuture forces all callbacks to execute on a separate thread pool (ForkJoinPool.commonPool() by default, or ClientResources.eventExecutorGroup() for MultiDbConnectionFuture). This ensures:

  • Event loop threads are never blocked by user code
  • Sync operations in callbacks are safe
  • No deadlocks even with blocking operations

Implementation Details:

  • All non-async methods (thenApply, thenAccept, etc.) delegate to their async variants
  • Custom executor can be provided for fine-grained control
  • The exceptionally() method is safe as-is (only runs on exception, doesn't block)

API Usage

// Asynchronous connection
MultiDbClient client = MultiDbClient.create(configs);
MultiDbConnectionFuture<String, String> future =
    client.connectAsync(StringCodec.UTF8);

// Non-blocking - can do other work here

// Wait for connection when needed
StatefulRedisMultiDbConnection<String, String> connection = future.get();

// SAFE: Callbacks run on separate thread pool, not event loop
future.thenApply(conn -> {
    // This is safe even though sync() blocks!
    return conn.sync().ping();
}).thenAccept(result -> {
    System.out.println("PING result: " + result);
}).exceptionally(ex -> {
    // Handle error
    ex.printStackTrace();
    return null;
});

// Can also convert to CompletableFuture if needed
CompletableFuture<StatefulRedisMultiDbConnection<String, String>> cf = future.toCompletableFuture();

Breaking Changes

None. This is a purely additive change that maintains full backward compatibility.

Documentation

  • Added comprehensive JavaDoc for all new methods and classes
  • Updated method documentation in MultiDbClient interface
  • Enhanced JavaDoc for synchronous connect() method to clarify blocking behavior
  • Documented deadlock prevention mechanism in BaseConnectionFuture and MultiDbConnectionFuture
  • Added code examples showing safe usage of sync operations in callbacks

Files Changed

New Files

  • src/main/java/io/lettuce/core/BaseConnectionFuture.java (311 lines)
  • src/main/java/io/lettuce/core/failover/MultiDbConnectionFuture.java (85 lines)
  • src/main/java/io/lettuce/core/failover/MultiDbAsyncConnectionBuilder.java (432 lines)
  • src/test/java/io/lettuce/core/failover/MultiDbAsyncConnectionBuilderUnitTests.java (392 lines)

Modified Files

  • src/main/java/io/lettuce/core/failover/MultiDbClient.java
  • src/main/java/io/lettuce/core/failover/MultiDbClientImpl.java
  • src/main/java/io/lettuce/core/failover/RedisDatabaseImpl.java
  • src/main/java/io/lettuce/core/failover/StatusTracker.java
  • src/test/java/io/lettuce/core/failover/CircuitBreakerMetricsIntegrationTests.java
  • src/test/java/io/lettuce/core/failover/DatabaseCommandTrackerUnitTests.java
  • src/test/java/io/lettuce/core/failover/DatabaseEndpointCallbackTests.java
  • src/test/java/io/lettuce/core/failover/DatabasePubSubEndpointTrackerTests.java
  • src/test/java/io/lettuce/core/failover/HealthCheckIntegrationTests.java

Testing

All tests pass successfully:

  • ✅ 13 new unit tests for MultiDbAsyncConnectionBuilder
  • ✅ Enhanced integration tests with standardized test tags
  • ✅ All existing tests continue to pass
  • ✅ No regressions

@atakavci atakavci requested review from ggivo and uglide January 2, 2026 15:01
@atakavci atakavci self-assigned this Jan 2, 2026
@atakavci atakavci added the type: feature A new feature label Jan 2, 2026
@atakavci atakavci marked this pull request as draft January 5, 2026 12:34
@atakavci atakavci marked this pull request as ready for review January 6, 2026 09:42
@atakavci atakavci force-pushed the failover/asyncConnect branch from 355db5b to c47d840 Compare January 6, 2026 12:03
@atakavci atakavci force-pushed the failover/asyncConnect branch from 68d5b36 to 78a1f99 Compare January 7, 2026 00:20
Copy link
Copy Markdown

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

❌ The following Jit checks failed to run:

  • static-code-analysis-semgrep-pro

#jit_bypass_commit in this PR to bypass, Jit Admin privileges required.

More info in the Jit platform.

Copy link
Copy Markdown
Contributor

@ggivo ggivo left a comment

Choose a reason for hiding this comment

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

LGTM

Other than what we discussed, that it is better not filter out unhealthy connections, I added some questions for my understanding.

@atakavci atakavci requested a review from ggivo January 12, 2026 15:00
@atakavci atakavci merged commit 5ff0966 into redis:feature/automatic-failover-1 Jan 14, 2026
13 of 14 checks passed
atakavci added a commit that referenced this pull request Feb 6, 2026
* [automatic-failover] Improve extensibility that is needed for automatic-failover feature (#3507)

* - improve extensbility that will needed in aa-failover feature

* - suppresswarnings and remove casting

* [automatic-failover] Draft implementation for automatic-failover (#3508)

* - draft implementation for automatic-failover

* - remove commented out tests

* - format

* - fix failing test

* - fix flaky test

* - fix multidbpusub subscriptions handover test

* - wait for subscriptions with failing test

* [automatic-failover]  Make AbstractRedisClient implements BaseRedisClient  (#3513)

* - move BaseRedisClient to core package and add it to AbstractRedisClient

* - add override annotations to AbstractRedisClient

* [automatic-failover]  Support for dynamic add/remove endpoints (#3517)

* - Add/Remove databases safely

* - secure switchToDatabase

* - guard listeners and db switch against race conditions.

* feedbacks from @ggivo
- add close to both MultiDbConnection and CircuitBreaker
- skip switchToDatabase when source and destination is same db

* - add test around attempt to switch to same db

* [automatic-failover] Support double-threshold logic with circuitbreaker (#3522)

* - simplfy tracking exceptions check
- add metrics evaluation tests for double-threshold
- add more tests on CB evaluates metrics and state transition, including edge cases

* - tune number of success/failures in test case

* - Add recordResult(Throwable), recordSuccess(), and recordFailure() public methods to CircuitBreaker
- Add getSnapshot() public method to expose metrics directly
- Change getMetrics() to package-private (internal use only)
- Simplify handleFailure() in endpoint implementations to use recordResult()
- Update all tests to use new public API
- Drop repeating test case  shouldOpenImmediatelyWhenMinimumCountReachedAndRateIsZero

* - fix test cases; drop unnecessary calls to evaluateMetrics when there is call to recordFailure

* [automatic failover] Implement sliding time window metrics tracker (#3521)

* abstract clock for easy testing

* Improve LockFreeSlidingWindowMetrics: fix bugs and add tests

Bug Fixes:
- Fix: Ensure snapshot metrics remain accurate after a full window rotation
- Fix: events recorded exactly at bucket boundaries were miscounted
- Enforce window size % bucket size == 0
- Move LockFreeSlidingWindowMetricsUnitTests to correct package
  (io.lettuce.core.failover.metrics)

* remove unused reset methods

* extract interface for MetricsSnapshot

   - remove snapshotTime - not used & not correctly calcualted
   - remove reset metrics - unused as of now

* add LockFreeSlidingWindowMetrics benchmark test

* performance tests moved to metrics package

* replace with port from reselience4j

* update copyrights

* format

* clean up javadocs

* clean up
   - fix incorrect javadoc
   - fix failing benchmark

* [automatic failover] Hide failover metrics implementation

 - CircuitBreakerMetrics, MetricsSnapshot - public
 - metrics implementation details stay inside io.lettuce.core.failover.metrics
 - Update CircuitBreaker to obtain its metrics via CircuitBreakerMetricsFactory.createLockFree()

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* rename createLockFree -> createDefaultMetrics

* address review comments by @atakavci

    - remove CircuitBreakerMetrics, CircuitBreakerMetricsImpl
    - rename SlidingWindowMetrics -> CircuitBreakerMetrics

* format

* Enforce min-window size of 2 buckets

  Current implementation requires at least 2 buckets window
        With windowSize=1, only one node is created with next=null
        When updateWindow() advances the window it sets HEAD to headNext, which is null for a single-node window
        On the next call to updateWindow(), tries to access head.next but head is now null, causing:
        NullPointerException: Cannot read field "next" because "head" is null

* Clean-up benchmark

   - benchmark matrix
       threads (1,4)
       window_size ("2", "30", "180")
   - performs 1_000_000 ops in simulated 5min test window
   - benchmark record events
   - benchmark record & read snapshot

* remove MetricsPerformanceTests.java

  - no reliable way to assert on performance, instead added basic benchmark test to benchmark  recording/snapshot reading average times
 - gc benchmarks are available for local testing

* reset method removed

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply suggestion from @atakavci

Co-authored-by: atakavci <a_takavci@yahoo.com>

* Update src/main/java/io/lettuce/core/failover/metrics/CircuitBreakerMetrics.java

Co-authored-by: Tihomir Krasimirov Mateev <tihomir.mateev@redis.com>

* add missing license header and javadoc

* add missing license header and javadoc

* correct author for jmh failover metrics

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: atakavci <a_takavci@yahoo.com>
Co-authored-by: Tihomir Krasimirov Mateev <tihomir.mateev@redis.com>

* [automatic failover] CAE-1861: Atomic lock-free metrics reset on CircuitBreaker state transitions (#3527)

* abstract clock for easy testing

* Improve LockFreeSlidingWindowMetrics: fix bugs and add tests

Bug Fixes:
- Fix: Ensure snapshot metrics remain accurate after a full window rotation
- Fix: events recorded exactly at bucket boundaries were miscounted
- Enforce window size % bucket size == 0
- Move LockFreeSlidingWindowMetricsUnitTests to correct package
  (io.lettuce.core.failover.metrics)

* remove unused reset methods

* extract interface for MetricsSnapshot

   - remove snapshotTime - not used & not correctly calcualted
   - remove reset metrics - unused as of now

* add LockFreeSlidingWindowMetrics benchmark test

* performance tests moved to metrics package

* replace with port from reselience4j

* update copyrights

* format

* clean up javadocs

* clean up
   - fix incorrect javadoc
   - fix failing benchmark

* [automatic failover] Hide failover metrics implementation

 - CircuitBreakerMetrics, MetricsSnapshot - public
 - metrics implementation details stay inside io.lettuce.core.failover.metrics
 - Update CircuitBreaker to obtain its metrics via CircuitBreakerMetricsFactory.createLockFree()

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* rename createLockFree -> createDefaultMetrics

* address review comments by @atakavci

    - remove CircuitBreakerMetrics, CircuitBreakerMetricsImpl
    - rename SlidingWindowMetrics -> CircuitBreakerMetrics

* format

* Enforce min-window size of 2 buckets

  Current implementation requires at least 2 buckets window
        With windowSize=1, only one node is created with next=null
        When updateWindow() advances the window it sets HEAD to headNext, which is null for a single-node window
        On the next call to updateWindow(), tries to access head.next but head is now null, causing:
        NullPointerException: Cannot read field "next" because "head" is null

* Clean-up benchmark

   - benchmark matrix
       threads (1,4)
       window_size ("2", "30", "180")
   - performs 1_000_000 ops in simulated 5min test window
   - benchmark record events
   - benchmark record & read snapshot

* remove MetricsPerformanceTests.java

  - no reliable way to assert on performance, instead added basic benchmark test to benchmark  recording/snapshot reading average times
 - gc benchmarks are available for local testing

* reset method removed

* reset circuit breaker metrics on state transition

* fix test : shouldMaintainMetricsAfterSwitch()

CB metrics are updated async on command completion, meaning waiting on command completion threads might proceed before metrics snapshot is updated.

* format

* evaluateMetrics - javadocs & make it package private

* format

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* [automatic-failover] Implement weighted endpoint selection (#3519)

* -  drop RedisDatabaseConfig

- add HealthStatus

* - set default healthStatus.Healthy

* - review from @ggivo, improve readability

* review from @tishun
- rename predicate function
- add javadoc

* - format

* - fix java docs

* - format

* [automatic-failover] Integrate health checks with probing policies and retry logic (CAE-1685) (#3541)

* initial port Jedis health monitoring

* wip integrate healthchecks

* formating

* formating

* add test case plan

* Endpoints without health checks configured should return HEALTHY

Changes
 - add connection.getHealthStatus(RedisUri endpoint)
 - HEALTHY - returned for Databases without health checks configured
 - add test

* Create MultiDbClient with custom health check strategy supplier

Changes
 - add test to ensure health status changes from custom health checks are reflected

* Create MultiDbClient with custom health check strategy supplier

Changes
 - add test to ensure health status changes from custom health checks are reflected

* faster await timeout

* add test - use different health check strategies for different endpoints

* wait for initial healthy database

* add test - configure health check interval and timeout

* add test - trigger failover when health check detects unhealthy endpoint

* add test - should not failover to unhealthy endpoints

* add test - Should trigger failover via circuit breaker even when health check returns HEALTHY

* reduce await poll interval in HealthCheckIntegrationTest

* mark un-implemented tests are disabled

* add test - Should transition from UNKNOWN to HEALTHY

* add test - Should create health check when adding new database

* fix - Should stop health check when removing  database

* add test - Should stop health check when removing  database

* add test - HealthCheckLifecycleTests
  - Should start health checks automatically when connection is created
  - Should stop health checks when connection is closed

* fix HealthCheck not stopped on StatefulRedisMultiDbConnection.close()

* remove HealthStatusListenerTests stubs, health check events, not exposed publicly

* format

* add health checks unit test

* clean up

   - rename health check thread names to lettuce-*
   - clean up warnings
   - format
   - javadocs & autor updated

* address failing tests

  - Update  StatefulMultiDbConnectionIntegrationTests to account for added additional test server in MultiDbTestSupport
  - Junit4  @after replaced with JUnit5

* address failing tests

  - Update  StatefulMultiDbConnectionIntegrationTests to account for added additional test server in MultiDbTestSupport
  - Junit4  @after replaced with JUnit5

* package private StatusTracker

* make healthStatusManager required when creating MultiDbStatefullConnection

* remove un-implemented probing integration tests

 - covered with unit tests

* introduce isHealthy() to replace getHealthStatus()

* register listeners before adding HealthChecks

* [automatic failover] Integrate circuitbreaker into each DefaultEndpoint/PubSubEndpoint (#3543)

* - move CB creation responsibility from RedisDatabase to client

* - introduce interface for CB

* - add CircuitBreaker interface
- introduce 'CircuitBreakerGeneration' to track CB state changes and issue 'recordResult' on correct stateholder
- apply command rejections whenCB is not CLOSED

* - fix typo

* - add metricsWindowSize to CircuitBreakerConfig
-  renaming DatabaseEndpoint.bind
-  add java docs
- add tests for Command.onComplete callbacsk for registered in DatabaseEndpoint
- introduce toxiproxy
- add circuitbreaker test to veify metrics collection and failover triggers

* - fix test

* - fix failing test due to order of listeners in CB state change events

* on feedbacks from @ggivo
 - drop record functions from CB interface
- revisit exposed functions on CB impl
- handle and record exception in  databaseendpoint.write
- fix tests
- get rid of thread.sleep's in tests

* - remove thread.sleep from test

* - format

* - limit visibility
- improve metrics objects for testability
- drop use of thread.sleep in DatabaseEndpointCallbackTests

* - revisit the tests to provide the assertions they claim in comments.

* - test to check commands failing after endpoint switch

* - formatting

* - change accesibility of CircuitBreakerGeneration
- drop metricsFactory instance approach
- fix naming typo
- drop TestMetricsFActory
- improve reflectinTestUtils

* feedback from @ggivo
-  drop recordFailure/recordsuccess from CircuitBreakerImpl

* feedback from @ggivo
- revisit CircuitBreakerGeneration interface

* [automatic failover]  Implement ping health check (CAE-1687) (#3564)

* add Ping strategy

* add PingStrategyIntegrationTests

add integration test

* health checks refactored (inject DatabaseConnectionProvider instead ClientOptions

Inject DatabaseConnectionProvider into HealthCheckStrategySupplier's. Injecting per DB connection factory allows reuse of  MultiDB client resources

  - ClientOptions no longer propagated to HealthCheckStrategySupplier
  - HealthCheckStrategySupplier refactored to use DatabaseConnectionProvider

* clean up

  - renamed DatabaseConnectionProvider -> DatabaseRawConnectionFactory
  - api docs updated

* format

* Fix sporadic test failures

 - Shared TestClientResources shutdown during tests, caused subsequent test to fail.

* clean up - rename internal vars

* clean up

   - add unit test
   - remove unused HealthCheckStrategySupplier DEFAULT_WITH_PROVIDER

* [automatic failover] Builder APIs for DatabaseConfig and CircuitBreakerConfig  (CAE-1695) (#3571)

* add DatabaseConfig.Builder

* healthCheckStrategySupplier now defaults to PingStrategy.DEFAULT in the builder

 - When using the builder without setting healthCheckStrategySupplier: Health checks will use PingStrategy.DEFAULT
 - When explicitly setting to null: Health checks will be disabled (as documented)
 - When setting to a custom supplier: Uses the custom health check strategy

 Example Usage:
 // Uses PingStrategy.DEFAULT for health checks
 DatabaseConfig config1 = DatabaseConfig.builder(uri)
     .weight(1.0f)
     .build();

 // Explicitly disables health checks
 DatabaseConfig config2 = DatabaseConfig.builder(uri)
     .healthCheckStrategySupplier(null)
     .build();

 // Uses custom health check strategy
 DatabaseConfig config3 = DatabaseConfig.builder(uri)
     .healthCheckStrategySupplier(customSupplier)
     .build();

* HealthCheckStrategySupplier.NO_HEALTH_CHECK instead null

* Remove DatabaseConfig constructors

// To create DatabaseConfig use provided builder
DatabaseConfig config = DatabaseConfig.builder(redisURI)
    .weight(1.5f)
    .clientOptions(options)
    .circuitBreakerConfig(cbConfig)
    .healthCheckStrategySupplier(supplier)
    .build();

* remove redundant public modifiers

* Builder for CircuitBreakerConfig

// Minimal configuration with defaults
CircuitBreakerConfig config = CircuitBreakerConfig.builder().build();

// Custom configuration
CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .failureRateThreshold(25.0f)
    .minimumNumberOfFailures(500)
    .metricsWindowSize(5)
    .build();

// With custom tracked exceptions
Set<Class<? extends Throwable>> customExceptions = new HashSet<>();
customExceptions.add(RuntimeException.class);

CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .failureRateThreshold(15.5f)
    .minimumNumberOfFailures(200)
    .trackedExceptions(customExceptions)
    .metricsWindowSize(3)
    .build();

* enforce min window size of 2s

* tracked exceptions should not be null

* add convenience methods for Tracked Exceptions

//Combine add and remove
CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .addTrackedExceptions(MyCustomException.class)
    .removeTrackedExceptions(TimeoutException.class)
    .build();

// Replace all tracked exceptions
Set<Class<? extends Throwable>> customExceptions = new HashSet<>();
customExceptions.add(RuntimeException.class);
customExceptions.add(IOException.class);
CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .trackedExceptions(customExceptions)
    .build();

* remove option to configure per database clientOptions till #3572 is resolved

* Disable health checks in test configs to isolate circuit breaker testing

Configure DB1, DB2, and DB3 with NO_HEALTH_CHECK to prevent health check
interference when testing circuit breaker failure detection.

* forma

* clean up

* address review comments (Copilot)

* Remove unused redisURI parameter from PingStrategy constructors (#3573)

The redisURI parameter in PingStrategy constructors was never used in the
implementation. The actual endpoint URI is passed to doHealthCheck() method
when performing health checks, making the constructor parameter redundant.

Changes:
- Removed RedisURI parameter from both PingStrategy constructors
- Updated DEFAULT supplier to use lambda instead of method reference

Remove unused redisURI parameter from PingStrategy constructors

The redisURI parameter in PingStrategy constructors was never used in the
implementation. The actual endpoint URI is passed to doHealthCheck() method
when performing health checks, making the constructor parameter redundant.

Changes:
- Removed RedisURI parameter from both PingStrategy constructors
- Updated DEFAULT supplier to use lambda instead of method reference

# Conflicts:
#	src/test/java/io/lettuce/core/failover/health/PingStrategyIntegrationTests.java

* [automatic failover] Add example for automatic failover (#3568)

* add DatabaseConfig.Builder

* healthCheckStrategySupplier now defaults to PingStrategy.DEFAULT in the builder

 - When using the builder without setting healthCheckStrategySupplier: Health checks will use PingStrategy.DEFAULT
 - When explicitly setting to null: Health checks will be disabled (as documented)
 - When setting to a custom supplier: Uses the custom health check strategy

 Example Usage:
 // Uses PingStrategy.DEFAULT for health checks
 DatabaseConfig config1 = DatabaseConfig.builder(uri)
     .weight(1.0f)
     .build();

 // Explicitly disables health checks
 DatabaseConfig config2 = DatabaseConfig.builder(uri)
     .healthCheckStrategySupplier(null)
     .build();

 // Uses custom health check strategy
 DatabaseConfig config3 = DatabaseConfig.builder(uri)
     .healthCheckStrategySupplier(customSupplier)
     .build();

* HealthCheckStrategySupplier.NO_HEALTH_CHECK instead null

* Remove DatabaseConfig constructors

// To create DatabaseConfig use provided builder
DatabaseConfig config = DatabaseConfig.builder(redisURI)
    .weight(1.5f)
    .clientOptions(options)
    .circuitBreakerConfig(cbConfig)
    .healthCheckStrategySupplier(supplier)
    .build();

* remove redundant public modifiers

* Builder for CircuitBreakerConfig

// Minimal configuration with defaults
CircuitBreakerConfig config = CircuitBreakerConfig.builder().build();

// Custom configuration
CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .failureRateThreshold(25.0f)
    .minimumNumberOfFailures(500)
    .metricsWindowSize(5)
    .build();

// With custom tracked exceptions
Set<Class<? extends Throwable>> customExceptions = new HashSet<>();
customExceptions.add(RuntimeException.class);

CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .failureRateThreshold(15.5f)
    .minimumNumberOfFailures(200)
    .trackedExceptions(customExceptions)
    .metricsWindowSize(3)
    .build();

* enforce min window size of 2s

* tracked exceptions should not be null

* add convenience methods for Tracked Exceptions

//Combine add and remove
CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .addTrackedExceptions(MyCustomException.class)
    .removeTrackedExceptions(TimeoutException.class)
    .build();

// Replace all tracked exceptions
Set<Class<? extends Throwable>> customExceptions = new HashSet<>();
customExceptions.add(RuntimeException.class);
customExceptions.add(IOException.class);
CircuitBreakerConfig config = CircuitBreakerConfig.builder()
    .trackedExceptions(customExceptions)
    .build();

* remove option to configure per database clientOptions till #3572 is resolved

* Disable health checks in test configs to isolate circuit breaker testing

Configure DB1, DB2, and DB3 with NO_HEALTH_CHECK to prevent health check
interference when testing circuit breaker failure detection.

* forma

* clean up

* address review comments (Copilot)

* Add example for automatic failover

* Use builders

* shutdown primary instance

* remove unused imports

* Update src/test/java/io/lettuce/examples/AutomaticFailover.java

Co-authored-by: atakavci <a_takavci@yahoo.com>

* revert accidentally disabled user timeout config

---------

Co-authored-by: ggivo <ivo.gaydazhiev@redis.com>
Co-authored-by: atakavci <a_takavci@yahoo.com>

* Merge remote-tracking branch 'origin/main' into feature/automatic-failover-1 (#3575)

* add Benchmark (jmh) benchmark result for 1343845

* Bump to 8.4-GA-pre.3 (#3516)

* add Benchmark (jmh) benchmark result for e8d59fc

* Add official 8.4 to test matrix and make it default (#3520)

* Add support for XREADGROUP CLAIM arg (#3486)

* Add support for XREADGROUP CLAIM arg

* Add NOACK scenario in ITs

* Fix NOACK IT scenario. Add test.

* Implement new fields as integers. Fix tests.

* Rename values for consistency.

* Address some comments from code review

* add Benchmark (jmh) benchmark result for 295546c

* Add support CAS/CAD (#3512)

* Implement CAS/CAD commands

* Add tests

* Fix readonly commands count

* Remove not needed license comments.

* Implement msetex command (#3510)

* Implement msetex command

* Refactor to use SetArgs

* Use dedicated MSetExArgs for MSETEX command

* Fix formatting

* Keep only instant/duration API

* Rm not needed license comment.

* Fix tests

* Preserve null values when parsing SearchReplies (#3518)

EncodedComplexOutput was skipping null values instead of passing them on. Then SearchReplyParser needs to store null values as they are and not try to decode them.
This affected both RESP2 and RESP3 parsing.

Added two integration tests in RediSearchAggregateIntegrationTests to verify that nulls in JSON documents are parsed correctly.

* add Benchmark (jmh) benchmark result for 0796a4e

* Modify release notes and bum pom version. (#3525)

* add Benchmark (jmh) benchmark result for 7fefd6a

* add Benchmark (jmh) benchmark result for 838fe47

* add Benchmark (jmh) benchmark result for 73a7bab

* add Benchmark (jmh) benchmark result for 0e49f73

* SearchArgs.returnField with alias produces malformed redis command #3528 (#3530)

* add Benchmark (jmh) benchmark result for a4eab37

* fix consistency with get(int) that returns wrapped (#3464)

DelegateJsonObject/DelegateJsonArray for nested structures

Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com>

* Bumping Netty to 4.2.5.Final (#3536)

* add Benchmark (jmh) benchmark result for 274af38

* add Benchmark (jmh) benchmark result for 8f2080a

* add Benchmark (jmh) benchmark result for fe79196

* add Benchmark (jmh) benchmark result for 289398b

* add Benchmark (jmh) benchmark result for 2f226a6

* add Benchmark (jmh) benchmark result for a1bb28d

* add Benchmark (jmh) benchmark result for d7e6a0a

* add Benchmark (jmh) benchmark result for 9230a17

* Add ftHybrid (#3540)

* Add ftHybrid

* rm max, withCount from SortBy

* refactor CombineArgs

* Move postprocessing inside PostProcessingArgs

* Refactor VectorSearchMethod

* Mark new files as experimental

* Format

* Fix RESP2 parsing

* Fix tests for previous versions

* Minor fixes in tests

* Format

* Add enabled on command

* Refactor scoring

* Tighten integration test with field assertions

* Rm commented loadALl

* Use keywords instead magic strings

* Fixed Range building

* Rm defaults from javadoc

* Expose method to add upstream driver libraries to CLIENT SETINFO payload (#3542)

* Expose method to add upstream driver libraries to CLIENT SETINFO payload

* Create a separate class to hold driver name and upstream drivers information

* Fix PR comments

* Update since tag

* add Benchmark (jmh) benchmark result for be132f9

* Release 7.2.0 (#3559)

* add Benchmark (jmh) benchmark result for fdcfb74

* Fix command queue corruption on encoding failures (#3443)

* Correctly handling the encoding error for Lettuce [POC]

Summary:
Add encoding error tracking to prevent command queue corruption

  - Add markEncodingError() and hasEncodingError() methods to RedisCommand interface
  - Implement encoding error flag in Command class with volatile boolean
  - Mark commands with encoding errors in CommandEncoder on encode failures
  - Add lazy cleanup of encoding failures in CommandHandler response processing
  - Update all RedisCommand implementations to support encoding error tracking
  - Add comprehensive unit tests and integration tests for encoding error handling

Fixes issue where encoding failures could corrupt the outstanding command queue by leaving failed commands in the stack without proper cleanup, causing responses to be matched to wrong commands.

Test Plan: UTs, Integration testing

Reviewers: yayang, ureview

Reviewed By: yayang

Tags: #has_java

JIRA Issues: REDIS-14050

Differential Revision: https://code.uberinternal.com/D19068147

* Fix error command handling code logic and add integration test for encoding failure

Summary: Fix error command handling code logic and add integration test for encoding failure

Test Plan: unittest, integration test

Reviewers: #ldap_storage_sre_cache, ureview, jingzhao

Reviewed By: #ldap_storage_sre_cache, jingzhao

Tags: #has_java

JIRA Issues: REDIS-14192

Differential Revision: https://code.uberinternal.com/D19271701

* latest changes

* Addressing the reactive streams issue

* Addressing the encoding issues
Addressing some general cases

* Formatting issues

* Test failures addressed

* Polishing

---------

Co-authored-by: Jing Zhao <jingzhao@uber.com>
Co-authored-by: Tihomir Mateev <tihomir.mateev@gmail.com>

* add Benchmark (jmh) benchmark result for f65b8d1

* add Benchmark (jmh) benchmark result for c6b42f0

* add Benchmark (jmh) benchmark result for 5c5f117

* add Benchmark (jmh) benchmark result for 329c39c

* add Benchmark (jmh) benchmark result for fa7e5d0

---------

Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com>
Co-authored-by: github-action-benchmark <github@users.noreply.github.com>
Co-authored-by: Aleksandar Todorov <a_t_todorov@yahoo.com>
Co-authored-by: Magnus Hyllander <magnus@hyllander.org>
Co-authored-by: Tihomir Krasimirov Mateev <tihomir.mateev@redis.com>
Co-authored-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com>
Co-authored-by: Viktoriya Kutsarova <viktoriya.kutsarova@gmail.com>
Co-authored-by: yang <43356004+yangy0000@users.noreply.github.com>
Co-authored-by: Jing Zhao <jingzhao@uber.com>
Co-authored-by: Tihomir Mateev <tihomir.mateev@gmail.com>

* [automatic failover] Mark APIs as experimental (CAE-2046) (#3574)

* Mark failover API as experimental

Mark all public classes and interfaces in the failover package as
@experimental to indicate that this API may change in future releases.
Update @SInCE annotations from 7.1/7.2/7.3 to 7.4

package-private implementation classes are not anotated as @experimental

* update version to 7.4.0-SNAPSHOT

* more experimental tags

 - classes outside failover package as experimental

* format

* update release notes for 7.4.0.BETA1 (#3578)

* fix : HealthCheckIntegrationTests nested test classes executed as unit tests (#3579)

* [automatic failover] Record failures for each attempt of write on channel including retries (#3583)

* - introduce MultiDbOutboundAdapter  handler to track retries and command results in the netty pipeline

* - unit and integrations tests for DatabaseCommandTracker and OutboundAdapter

* - reviews from @ggivo

* - format
- remove sharable

* [automatic failover] Make ClientOptions per Database(DatabaseConfig) instead of Client level (#3587)

* - apply thread local instance for clientOptions
- fix tests according to the clientOptions changes

* - fix failing tests

* - fix missing stream collector

* - undo test leftover

* - reviews from @ggivo

* - fix flaky test

* - fix flaky test

* [automatic failover] Implement thread-safe endpoint switch in StatefulMultiDbConnection (#3598)

* - introduce immutable redisURI
- fix potential issues in swithToDatabase with listeners and concurrent health/CB state changes
-  build  seperate switch operations for public and internal at multiDbConnection level

- format

- add copy ctor to RedisURI

- fix issues introduced with the last mistaken commit

* - add BaseRedisDatabase interface
- add some logging for failover
- Fix test timeout values

* -  add unit tests for statefulredismultidbconnectionimpl

* - refactor CircuitBreaker to use ID instead of RedisURI
- replace endpoint-based identification with string IDs.
- improve failover logic and database switching safety.
- add return value to switchTo() method.
- update tests to match new constructor signature.

* - fix failing test

* - fix impacted tests

* - polish

* - format

* - feedbacks from copilot

* - imporve inline docs and comments

* - feedback from copilot

* - format

* - fix  the test case

* - promote use of Db.getId
- fix incorrect logging

* - hide implementations for database and connection

* - feedback from @uglide , drop license headers

* Revert accidentally replaced jmh benchmark test includes

* [automatic failover][lettuce] Expose pluggable listeners interface for failover events (#3606)

* add DatabaseSwitchEvent

* add unit test

* add unit test

* expose getResource to BaseRedisClient interfcae

* update AutomaticFailover example

* clean up

* publish event outside switch exclusive lock

* publish event outside switch exclusive lock

* Add source connection to DatabaseSwitchEvent

* address review comments

* [automatic failover] Implement async creation support for StatefulRedisMultiDbConnection on MultiDbClient (#3600)

* -  squash changes from safeSwitch

* - draft for async connect with multiDb

* - init connection without "all  established" requirement
- add tests for thread local ClientOptions
- add async tracking to StatusTracker

* - refactor connectAsync

* - introduce AsyncConnectionBuilder

* - add tests
- polish

* - drop licence headers

* - connectAsync returns CompletableFuture
- revisit tests

* -rename test file

* - dedicated server instances

* - set port offset

* - drop connection field

* - introduce MultiDbConnectionFuture

* - fix tests

* - drop filtering healthy db on init

* - feedback from @ggivo

* [automatic failover] Implement client initialization and safe startup of MultiDbClient (#3613)

* -  squash changes from safeSwitch

* - draft for async connect with multiDb

* - init connection without "all  established" requirement
- add tests for thread local ClientOptions
- add async tracking to StatusTracker

* - refactor connectAsync

* - introduce AsyncConnectionBuilder

* - add tests
- polish

* - drop licence headers

* - connectAsync returns CompletableFuture
- revisit tests

* -rename test file

* - dedicated server instances

* - set port offset

* - drop connection field

* - introduce MultiDbConnectionFuture

* - fix tests

* - init with most weighted healhty

* - clean/refactor sync methods

* - apply generic parameters to support connectPubSubAsync

* -  use same rawc onnecttion factory

* - improve type safety with builder

* - improve generic types

* - refactor multidb connection to abstract and seperate child classes per regular conn and pubsub one

* - handle corner cases with health state transitions

* - feedback from copilot

* - update javadocs

* - fix completion issues and test cases

* - fix intermittent fails; add wait for endpoints to init

* - unit test multidbasyncbuilder

* - add integration tests
- fix test proxy setup

* - fix issue in findInitialDbCandidate
- replace toxiproxy with testAsyncConnectionBuilder
- revisit async builder unit tests

* - fix premature shutdown in test

* - fix issue in findInitialDbCandidate

* add log

* undo docker start params

* - wait on endpoints for proper testing

* - close databases properly on conneciton close

* [automatic failover] Simple renaming of factory classes in MultiDb (#3619)

* [automatic failover] Register StatefulRedisMultiDbConnectionImpl as closeable resource (#3622)

* - register multidb as closeable resource
- destroy resources when multiDbConnBuilder fails

* - exclude integration tagged classes with surefire runs

* - remove shutdown calls

* - polish

* - rename

* - change approach with ConnectionFuture

* -reorder operations in closeAsync

* - fix test

* [automatic failover] CAE-2220: Add minimal Netty-based HTTP client for health checks (#3620)

* CAE-2220: Add minimal Netty-based HTTP client for health checks

Introduce the initial version of a lightweight HTTP client built directly on Netty
for HTTP-based health checks used by the automatic failover mechanism.

The client supports GET requests only, uses Netty primitives exclusively,
supports HTTPS via TLS handlers

* Add pending request completion on connection close

Complete pending HTTP requests with IOException when connection closes unexpectedly via channelInactive handler.

* Fix connection timeout test to validate actual timeout behavior

* added HttpConnection.closeAsync

* address review comments

- Tag  NetyHttpClient integration test
- unmodifiable DefaultResponse body and headers
- Add imports to resolve qualified class names access
- remove @experimental from package private classes
- add port to host header
- exception handling improvements
- renamed DefaultConfig  -> DefaultConnectionConfig
- Copyright fixed
- DefaultConnectionConfig validations added
- NettyHttpClient extracted constants for default ports
- NettyHttpClient shutdown with configurable timeouts

* fix tests

* address review comments

- remove getResponseBodyAsByteBuffer

* [automatic failover] CAE-2220: Provider for shared HTTP client instances (#3621)

* CAE-2220: Add minimal Netty-based HTTP client for health checks

Introduce the initial version of a lightweight HTTP client built directly on Netty
for HTTP-based health checks used by the automatic failover mechanism.

The client supports GET requests only, uses Netty primitives exclusively,
supports HTTPS via TLS handlers

* Add pending request completion on connection close

Complete pending HTTP requests with IOException when connection closes unexpectedly via channelInactive handler.

* Fix connection timeout test to validate actual timeout behavior

* added HttpConnection.closeAsync

* CAE-2220: Provider for shared HTTP client instances

Introduce HttpClientResources for managing shared HTTP client instances
with reference counting to reduce resource usage. Add HttpClientProvider
SPI for pluggable implementations with NettyHttpClientProvider as the
default.

* add HttpClientResources unit test

* format

* address review comments

- Tag  NetyHttpClient integration test
- unmodifiable DefaultResponse body and headers
- Add imports to resolve qualified class names access
- remove @experimental from package private classes
- add port to host header
- exception handling improvements
- renamed DefaultConfig  -> DefaultConnectionConfig
- Copyright fixed
- DefaultConnectionConfig validations added
- NettyHttpClient extracted constants for default ports
- NettyHttpClient shutdown with configurable timeouts

* fix tests

* address review comments

- remove getResponseBodyAsByteBuffer

* address review comments

- remove reference counting & locking
- add missing service provided descriptor

* fix copyrights

* [automatic failover] Add lag-aware health check strategy for failover (#3631)

* CAE-2220: Add minimal Netty-based HTTP client for health checks

Introduce the initial version of a lightweight HTTP client built directly on Netty
for HTTP-based health checks used by the automatic failover mechanism.

The client supports GET requests only, uses Netty primitives exclusively,
supports HTTPS via TLS handlers

* Add pending request completion on connection close

Complete pending HTTP requests with IOException when connection closes unexpectedly via channelInactive handler.

* Fix connection timeout test to validate actual timeout behavior

* added HttpConnection.closeAsync

* CAE-2220: Provider for shared HTTP client instances

Introduce HttpClientResources for managing shared HTTP client instances
with reference counting to reduce resource usage. Add HttpClientProvider
SPI for pluggable implementations with NettyHttpClientProvider as the
default.

* add HttpClientResources unit test

* format

* Add lag-aware health check strategy for failover

Implement lag-aware health check strategy for MultiDbFailover client that considers replication lag when evaluating database health. Includes async RedisRestClient for REST API health checks.

Relates to: CAE-1689

* address review comments

- Tag  NetyHttpClient integration test
- unmodifiable DefaultResponse body and headers
- Add imports to resolve qualified class names access
- remove @experimental from package private classes
- add port to host header
- exception handling improvements
- renamed DefaultConfig  -> DefaultConnectionConfig
- Copyright fixed
- DefaultConnectionConfig validations added
- NettyHttpClient extracted constants for default ports
- NettyHttpClient shutdown with configurable timeouts

* fix tests

* address review comments

- remove getResponseBodyAsByteBuffer

* address review comments

- remove reference counting & locking
- add missing service provided descriptor

* fix copyrights

* Apply changes after refactor HttpClientResources to lazy singleton and change BDB uid type to Long

- Remove reference counting (acquire/release) from HttpClientResources, use get() API
- Change BdbInfo uid from String to Long
- Use createJsonValue(String) instead of loadJsonValue(ByteBuffer) in RedisRestClient
- Improve error message when no HTTP client provider is available
- Add license header and unit test tag to RedisRestClientUnitTests

* Add LagAwareStrategy API docs and refactor ConfigBuilder to Builder

- Add class-level Javadoc with Redis Enterprise availability API details
- Rename ConfigBuilder to Builder for consistency
- Make restEndpoint and credentialsSupplier settable via builder methods
- Fix builder() to return usable instance instead of throwing exception

* update LagAwareStrategy API docs

* address @tishun review comments

- improve exception handling
- do not store credentials in String while preparing basic auth header
- update availability_lag_tolerance ->  availabilityLagTolerance

* [automatic failover] Implement failback support (#3630)

* - introduce multidboptions
- support failback

* - addint unit+integration tests
- fix bumpy healthcheck probing test

* - reviews from copilot

* - fix flaky test

* - fix illegal port in test

* - remove assertion conflicting with logic

* - wait for endpoints

* - feedback from @tishun

* - fix assertion and failing tests

* - fix failing assertions in failback interval

* - review from @ggivo

* [automatic failover] Implement grace period on failover (#3636)

* - introduce multidboptions
- support failback

* - addint unit+integration tests
- fix bumpy healthcheck probing test

* - reviews from copilot

* - draft graceperiod implementation

* - remove graceperiod reset with failback task

* - fix connection init issue

* - fix tests that requires nofailback config

* - fix flaky test

* - fix illegal port in test

* - remove assertion conflicting with logic

* - wait for endpoints

* - add test for grace period

* - failing tests due to graceperiod

* - fix test extension

* - feedback from @tishun

* - fix assertion and failing tests

* - fix failing assertions in failback interval

* - feedback from @ggivo and @tishun

* - improve test duration

* - trim unnecessary check

* - review from @ggivo

* [automatic failover] CAE-1692 Apply/revisit defaults for thresholds and settings in configuration (#3641)

* configurable maxFailoverAttempts

* update gracePeriod default to 60s

* Revert "configurable maxFailoverAttempts"

This reverts commit 64d5656.

* [automatic failover] Handle "no healthy database available" cases (#3642)

* - test no healthy db available case

* - polish

* - improve flaky test

* - feedback form copilot

* [automatic failover] Tag failover types as experimental

* [automatic failover] Add support for initial db state policy configuration (#3644)

* - implement initial db states policy

* - fix atomicrefernce issue in abstractmultidbconnectionbuilder
- fix failing tests due to init policy changes

* - fix failing tests

* - feedback from copilot

* - format

* - adding unit and integ tests

* - fix name typo

* [automatic failover] CAE-2351 OPTIONAL: Send notification after X unsuccessfull failover attempts (#3646)

* added delayInBetweenFailoverAttempts to MultiDbOptions

* Created AllDatabasesUnhealthyEvent event

* lock-free failover retry

* tests

* mark new event experimental

* adress copilot comments

* move resetAttempt after we have successfully switched DB

* Disable maintenance events by default in MultiDB Client (#3651)

* [automatic failover] API changes in failover package  (#3654)

* - move exposed types to api package

* - revisit accesibility
- fix imports

* - revisit accessibility
- fix imports

* - fix imports in tests

* - introduce convenience class for healthCheckStrategy

* - drop experimental tags from package private

* Fix formatting in pom.xml

* fix intermittent test failure in NettyHttpClientIntegrationTests (#3656)

* format netty test fail

* [automatic failover] Add failover documentation for MultiDbClient (#3653)

* Add failover documentation for MultiDbClient
- docs/failover.md: New documentation covering:

  - Basic usage with weighted database configuration
  - DatabaseConfig, MultiDbOptions, and CircuitBreakerConfig settings
  - Health check strategies (PingStrategy, LagAwareStrategy)
  - Automatic and manual failback
  - Dynamic database management
  - Database switch events and troubleshooting

- docs/advanced-usage.md: Add reference to failover documentation

* improve health checks description

* address review comments
  - correct json dependency
  - RedisURI and DabaseConfig together for better readability

* example how to provide custom healthcheck

* example how to provide custom healthcheck using abstract base class

* update the Failback section with the more accurate description:

* address review comments by @astark and @atakavci

* add Need help section

---------

Signed-off-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com>
Co-authored-by: atakavci <a_takavci@yahoo.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Tihomir Krasimirov Mateev <tihomir.mateev@redis.com>
Co-authored-by: Igor Malinovskiy <u.glide@gmail.com>
Co-authored-by: github-action-benchmark <github@users.noreply.github.com>
Co-authored-by: Aleksandar Todorov <a_t_todorov@yahoo.com>
Co-authored-by: Magnus Hyllander <magnus@hyllander.org>
Co-authored-by: NeatGuyCoding <15627489+NeatGuyCoding@users.noreply.github.com>
Co-authored-by: Viktoriya Kutsarova <viktoriya.kutsarova@gmail.com>
Co-authored-by: yang <43356004+yangy0000@users.noreply.github.com>
Co-authored-by: Jing Zhao <jingzhao@uber.com>
Co-authored-by: Tihomir Mateev <tihomir.mateev@gmail.com>
@atakavci atakavci deleted the failover/asyncConnect branch February 27, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants