环境上用的springboot 2.3.1, 项目上线已经两年,今天第一次遇到这个lettuce的Redis “Command timed out”,于是网上查了查资料,找一下原因和解决方法。
GitHub ISSUE:
https://github.com/lettuce-io/lettuce-core/issues?q=is%3Aissue+Command+timed+out+after
https://github.com/lettuce-io/lettuce-core/issues/1362
参考官方连接:
RedisCommandTimeoutException with a stack trace like:
io.lettuce.core.RedisCommandTimeoutException: Command timed out after 1 minute(s)
at io.lettuce.core.ExceptionFactory.createTimeoutException(ExceptionFactory.java:51)
at io.lettuce.core.LettuceFutures.awaitOrCancel(LettuceFutures.java:114)
at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:69)
at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
at com.sun.proxy.$Proxy94.set(Unknown Source)
Diagnosis:
-
Check the debug log (log level
DEBUGorTRACEfor the loggerio.lettuce.core.protocol) -
Take a Thread dump to investigate Thread activity
Cause:
Command timeouts are caused by the fact that a command was not completed within the configured timeout. Timeouts may be caused for various reasons:
-
Redis server has crashed/network partition happened and your Redis service didn’t recover within the configured timeout
-
Command was not

本文分析了SpringBoot应用中遇到的Redis命令超时问题,包括RedisCommandTimeoutException的诊断和可能的原因,如服务器故障、命令执行时间过长、配置不匹配、EventLoop阻塞等。提出了相应的解决方案,如调整SpringBoot的Redis配置、修改Redis服务器的tcp-keepalive参数、切换到Jedis客户端、添加心跳检查和优化服务器性能。同时,也提醒注意Redis的阻塞问题,如大对象操作、CPU竞争和网络延迟。

2857

被折叠的 条评论
为什么被折叠?



