spring-projects / spring-data-redis

Provides support to increase developer productivity in Java when using Redis, a key-value store. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-redis/
Apache License 2.0
1.77k stars 1.17k forks source link

How to disable lettuce retry and shutdown application, when redis is not available #3050

Closed Ilya-bmx closed 4 days ago

Ilya-bmx commented 6 days ago

I use StreamsBuilder spring-boot-starter-data-redis 3.1.2. by the way redis is available

2024-11-19 10:36:58,201 [lettuce-eventExecutorLoop-1-2] INFO i.l.core.protocol.ConnectionWatchdog - Reconnecting, last destination was 10.31.159.28/:6379 2024-11-19 10:37:08,208 [lettuce-nioEventLoop-4-1] WARN i.l.core.protocol.ConnectionWatchdog - Cannot reconnect to [10.31.159.28/:6379]: connection timed out: /10.31.159.28:6379 2024-11-19 10:37:08,301 [lettuce-eventExecutorLoop-1-3] INFO i.l.core.protocol.ConnectionWatchdog - Reconnecting, last destination was 10.31.159.28/:6379 2024-11-19 10:37:18,308 [lettuce-nioEventLoop-4-2] WARN i.l.core.protocol.ConnectionWatchdog - Cannot reconnect to [10.31.159.28/:6379]: connection timed out: /10.31.159.28:6379 2024-11-19 10:37:18,401 [lettuce-eventExecutorLoop-1-2] INFO i.l.core.protocol.ConnectionWatchdog - Reconnecting, last destination was 10.31.159.28/:6379 2024-11-19 10:37:28,408 [lettuce-nioEventLoop-4-3] WARN i.l.core.protocol.ConnectionWatchdog - Cannot reconnect to [10.31.159.28/:6379]: connection timed out: /10.31.159.28:6379 2024-11-19 10:37:28,602 [lettuce-eventExecutorLoop-1-1] INFO i.l.core.protocol.ConnectionWatchdog - Reconnecting, last destination was 10.31.159.28/:6379 2024-11-19 10:37:38,608 [lettuce-nioEventLoop-4-1] WARN i.l.core.protocol.ConnectionWatchdog - Cannot reconnect to [10.31.159.28/:6379]: connection timed out: /10.31.159.28:6379 2024-11-19 10:37:38,901 [lettuce-eventExecutorLoop-1-3] INFO i.l.core.protocol.ConnectionWatchdog - Reconnecting, last destination was 10.31.159.28/:6379 2024-11-19 10:37:48,908 [lettuce-nioEventLoop-4-2] WARN i.l.core.protocol.ConnectionWatchdog - Cannot reconnect to [10.31.159.28/:6379]: connection timed out: /10.31.159.28:6379 2024-11-19 10:37:49,501 [lettuce-eventExecutorLoop-1-2] INFO i.l.core.protocol.ConnectionWatchdog - Reconnecting, last destination was 10.31.159.28/:6379 2024-11-19 10:37:50,984 [lettuce-eventExecutorLoop-1-1] WARN o.s.b.a.d.r.RedisReactiveHealthIndicator - Redis health check failed org.springframework.dao.QueryTimeoutException: Redis command timed out at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:68) at org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection.lambda$translateException$0(LettuceReactiveRedisConnection.java:242) at reactor.core.publisher.Flux.lambda$onErrorMap$27(Flux.java:7201) at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94) at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onError(MonoFlatMapMany.java:255) at reactor.core.publisher.MonoNext$NextSubscriber.onError(MonoNext.java:93) at reactor.core.publisher.MonoNext$NextSubscriber.onError(MonoNext.java:93) at io.lettuce.core.RedisPublisher$ImmediateSubscriber.onError(RedisPublisher.java:895) at io.lettuce.core.RedisPublisher$State.onError(RedisPublisher.java:716) at io.lettuce.core.RedisPublisher$RedisSubscription.onError(RedisPublisher.java:357) at io.lettuce.core.RedisPublisher$SubscriptionCommand.onError(RedisPublisher.java:801) at io.lettuce.core.RedisPublisher$SubscriptionCommand.doOnError(RedisPublisher.java:797) at io.lettuce.core.protocol.CommandWrapper.completeExceptionally(CommandWrapper.java:128) at io.lettuce.core.protocol.CommandExpiryWriter.lambda$potentiallyExpire$0(CommandExpiryWriter.java:175) at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98) at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:153) at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:66) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: io.lettuce.core.RedisCommandTimeoutException: Command timed out after 1 minute(s) at io.lettuce.core.internal.ExceptionFactory.createTimeoutException(ExceptionFactory.java:59) at io.lettuce.core.protocol.CommandExpiryWriter.lambda$potentiallyExpire$0(CommandExpiryWriter.java:176) ... 8 common frames omitted 2024-11-19 10:37:50,984 [http-nio-8080-exec-7] WARN o.s.b.a.health.HealthEndpointSupport - Health contributor org.springframework.boot.actuate.autoconfigure.health.HealthEndpointConfiguration$AdaptedReactiveHealthContributors$1 (redis) took 60001ms to respond 2024-11-19 10:37:59,508 [lettuce-nioEventLoop-4-3] WARN i.l.core.protocol.ConnectionWatchdog - Cannot reconnect to [10.31.159.28/:6379]: connection timed out: /10.31.159.28:6379 2024-11-19 10:38:00,601 [lettuce-eventExecutorLoop-1-1] INFO i.l.core.protocol.ConnectionWatchdog - Reconnecting, last destination was 10.31.159.28/:6379 2024-11-19 10:38:10,608 [lettuce-nioEventLoop-4-1] WARN i.l.core.protocol.ConnectionWatchdog - Cannot reconnect to [10.31.159.28/:6379]: connection timed out: /10.31.159.28:6379 2024-11-19 10:38:12,701 [lettuce-eventExecutorLoop-1-3] INFO i.l.core.protocol.ConnectionWatchdog - Reconnecting, last destination was 10.31.159.28/:6379

mp911de commented 4 days ago

Set ClientOptions.autoReconnect to false. Alternatively, ClientOptions.disconnectedBehavior.