我们正在使用生菜 redis 库面临这个特定问题。我们收到太多 RedisCommandTimeoutException。我们在 redis-cli 中设置了 2 秒的超时,在 redis 慢日志中设置了 10 毫秒。虽然没有任何东西被记录在慢日志中,但我们的应用程序不断收到这个超时。
我们使用的代码如下
Duration timeout =
Duration.ofMillis(applicationProperties.redisTimeOut);
RedisClient client = RedisClient.create(RedisURI.create(applicationProperties.redisUrl));
client.setDefaultTimeout(timeout);
RedisCommands<String, String> commands = client.connect().sync();
Run Code Online (Sandbox Code Playgroud)
我们的应用程序中有大约 100 个线程可能正在使用此共享连接
我们收到的异常如下
io.lettuce.core.RedisCommandTimeoutException: Command timed out
at io.lettuce.core.LettuceFutures.awaitOrCancel(LettuceFutures.java:114)
at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:62)
at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)
at com.sun.proxy.$Proxy11.hmget(Unknown Source)
Run Code Online (Sandbox Code Playgroud)