question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
the3rdcommented, Apr 27, 2018

确实,当我将max.total设置成100时,就好了。 但是我不理解为什么需要这么多!

ps. 用Redission换掉Jedis怎么样,redis各类集群基本都支持了

0reactions
beiwei30commented, Feb 18, 2019

I think the reason is just like what you said, the resource pool get exhausted, and max.total does the trick.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found