[springboot, lettuce] io.lettuce.core.RedisCommandTimeoutException: Command timed out after

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

     环境上用的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

参考官方连接:

Lettuce Reference Guide

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:

  1. Check the debug log (log level DEBUG or TRACE for the logger io.lettuce.core.protocol)

  2. 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:

  1. Redis server has crashed/network partition happened and your Redis service didn’t recover within the configured timeout

  2. Command was not

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值