Deadlock when dozens of services registry to redis server
See original GitHub issue当注册十数个以上服务到redis注册中心时,存在很大概率的死锁,程序未能完成所有服务的注册。
com.alibaba.dubbo.registry.redis.RedisRegistry
@Override
public void doRegister(URL url) {
String key = toCategoryPath(url);
String value = url.toFullString();
String expire = String.valueOf(System.currentTimeMillis() + expirePeriod);
boolean success = false;
RpcException exception = null;
for (Map.Entry<String, JedisPool> entry : jedisPools.entrySet()) {
JedisPool jedisPool = entry.getValue();
try {
Jedis jedis = jedisPool.getResource(); // **HERE! 卡在这里,jedis资源耗尽了?**
try {
jedis.hset(key, value, expire);
jedis.publish(key, Constants.REGISTER);
success = true;
if (!replicate) {
break; // If the server side has synchronized data, just write a single machine
}
} finally {
jedis.close();
}
} catch (Throwable t) {
exception = new RpcException("Failed to register service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
}
}
if (exception != null) {
if (success) {
logger.warn(exception.getMessage(), exception);
} else {
throw exception;
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Deadlock when dozens of services registry to redis server #1677
@Override public void doRegister(URL url) { String key = toCategoryPath(url); String value = url.toFullString(); String expire = String.
Read more >Distributed Locks with Redis
Distributed locks are a very useful primitive in many environments where different processes must operate with shared resources in a mutually exclusive way....
Read more >Deadlock when accessing StackExchange.Redis
The deadlock occur when the active async worker thread in StackExchange.Redis completes a command and when the completion task is executed ...
Read more >Investigating timeout exceptions in StackExchange.Redis for ...
A server load of 100 (maximum value) signifies that the redis server has been busy all the time (has not been idle) processing...
Read more >Facing deadlock issue while acquiring the redis lock
I am working on POC of redis cluster. I am using it for following two use cases: distributed cache; distributed lock. But I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
确实,当我将max.total设置成100时,就好了。 但是我不理解为什么需要这么多!
ps. 用Redission换掉Jedis怎么样,redis各类集群基本都支持了
I think the reason is just like what you said, the resource pool get exhausted, and
max.total
does the trick.