redisson / redisson

Redisson - Easy Redis Java client and Real-Time Data Platform. Valkey compatible. Sync/Async/RxJava/Reactive API. Over 50 Redis or Valkey based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Spring, Tomcat, Scheduler, JCache API, Hibernate, RPC, local cache...
https://redisson.pro
Apache License 2.0
23.26k stars 5.34k forks source link

appear org.redisson.client.RedisResponseTimeoutException #3035

Closed chenpengliang0909 closed 4 years ago

chenpengliang0909 commented 4 years ago

您好: Hello:

在使用Redisson作为分布式锁时,不定期会出现RedisResponseTimeoutException(具体错误信息如下),已经按照之前的issue的回答中进行设置,包括设置pingConnectionInterval,以及nettyThreads,但是还是出现了该问题,目前不知道该怎么处理,非常希望能得到您的帮助,非常感谢。

When using Redisson as a distributed lock, RedisResponseTimeoutException will appear from time to time (the specific error message is as follows), which has been set in accordance with the answer to the previous issue, including setting pingConnectionInterval and nettyThreads, but this problem still occurs. I don’t know the How to deal with it, I really hope to get your help, thank you very much.

Expected behavior

[2020-09-07 10:49:47.411] [http-nio-9023-exec-7] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] [] [] [] - Servlet.service() for servlet [dispatcherServlet] in context with path [/activity/provider] threw exception [Request processing failed; nested exception is org.redisson.client.RedisResponseTimeoutException: Redis server response timeout (3000 ms) occured after 3 retry attempts. Command: (EVAL), params: [if (redis.call('exists', KEYS[1]) == 0) then redis.call('hset', KEYS[1], ARGV[2], 1); redis.call('pe..., 1, PrizeActivityServiceImpl:getActivityPrize, 10000, fab0e7c0-940c-423b-af4e-dd86dac6d31f:71], channel: [id: 0x7df78ed5, L:/172.20.2.62:51408 - R:172.18.215.46/172.18.215.46:6389]] with root cause org.redisson.client.RedisResponseTimeoutException: Redis server response timeout (3000 ms) occured after 3 retry attempts. Command: (EVAL), params: [if (redis.call('exists', KEYS[1]) == 0) then redis.call('hset', KEYS[1], ARGV[2], 1); redis.call('pe..., 1, PrizeActivityServiceImpl:getActivityPrize, 10000, fab0e7c0-940c-423b-af4e-dd86dac6d31f:71], channel: [id: 0x7df78ed5, L:/172.20.2.62:51408 - R:172.18.215.46/172.18.215.46:6389] at org.redisson.command.RedisExecutor$3.run(RedisExecutor.java:338) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:682) at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:757) at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:485) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748)

Redis version 5.0.5

Redisson version 3.11.5

Redisson configuration @configuration public class RedissonManager {

@Autowired private RedissonProperties redissonProperties;

@Bean public RedissonClient getRedissonSingle() { String address = "redis://"+redissonProperties.getHost() + ":" + redissonProperties.getPort(); Config config = new Config(); SingleServerConfig serverConfig = config.useSingleServer() .setPingConnectionInterval(1000) .setRetryInterval(1000) .setRetryAttempts(3) .setAddress(address); if(StringUtils.isNotBlank(redissonProperties.getPassword())) { serverConfig.setPassword(redissonProperties.getPassword()); } config.setCodec(new StringCodec()); config.setLockWatchdogTimeout(30*1000); config.setNettyThreads(64); return Redisson.create(config); } }

mrniko commented 4 years ago

3 retry attempts

means that command is not sent after every attempt in 1000ms as you defined in config. Check your network or try to increase nettyThreads to 96

chenpengliang0909 commented 4 years ago

检查网络是正常的,因为缓存的数据是能正常访问的,并且重启客户端应用后,这个异常消失,能正常使用锁了,很奇怪; checking the network is normal, because the cached data can be accessed normally, and after restarting the client application, this exception disappears and the lock can be used normally, which is strange

mrniko commented 4 years ago

Do you use RBatch object?

chenpengliang0909 commented 4 years ago

实现缓存的技术,不是使用Redisson,而是spring data redis;仅使用Redisson实现分布式锁,操作锁的工具类如下: The technology to implement caching is not Redisson, but spring data redis; only Redisson is used to implement distributed locks. The tools for operating locks are as follows:

@Component public class RedissonDistributedLockerUtils {

private RedissonDistributedLockerUtils () {}

@Autowired
private RedissonClient redissonClient;

private static RedissonDistributedLockerUtils lockerUtils;

public static boolean getTryLock(String lockKey, TimeUnit unit, int waitTime, int leaseTime) {
    RLock lock = lockerUtils.redissonClient.getLock(lockKey);
    try {
        return lock.tryLock(waitTime, leaseTime, unit);
    } catch (InterruptedException e) {
        return false;
    }
}

public static void unlock(String lockKey) {
    RLock lock = lockerUtils.redissonClient.getLock(lockKey);
    lock.unlock();
}

}

chenpengliang0909 commented 4 years ago

是否有对应的处理建议呢? Is there a corresponding treatment suggestion? @mrniko

mrniko commented 4 years ago

Do you use Redisson's implementation of spring data redis API?