Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lettuce fail over in cluster

I am trying to get Lettuce to connect to the newly promoted master (former slave) after the old one failed. But all writes stop. The writes continue after the failed host reconnects, now as a slave. And it continues to write to the new master (former slave).

I tried setting periodic topology refreshes, as well as adaptive ones on all events but it didn't help. Is there another setting I have to use?

This is how I configured the client:

final List<RedisURI> redisURIs = buildRedisURIs(redisServerSettings.getNodes());
final RedisClusterClient client = RedisClusterClient.create(clientResources, redisURIs);
final ClusterTopologyRefreshOptions refreshOptions =
        ClusterTopologyRefreshOptions.builder()
                                     .enableAllAdaptiveRefreshTriggers()
                                     .adaptiveRefreshTriggersTimeout(Duration.ofMinutes(2))
                                     .refreshTriggersReconnectAttempts(2)
                                     .enablePeriodicRefresh(Duration.ofMinutes(10))
                                     .build();
client.setOptions(ClusterClientOptions.builder().topologyRefreshOptions(refreshOptions).build());
like image 417
Armin Avatar asked Oct 15 '25 18:10

Armin


1 Answers

I solved the problem.

Because lettuce doesn't have a timeout normally, it waited forever for the response from the server. Setting the timeout caused some transactions to fail but after the failed transactions, the reads and writes continued.

like image 121
Armin Avatar answered Oct 18 '25 11:10

Armin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!