jedis icon indicating copy to clipboard operation
jedis copied to clipboard

'Could not get a resource from the pool' when using ShardedJedisPool

Open jinghong opened this issue 15 years ago • 5 comments

when working with ShardedJedisPool under moderate load, 'redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool' happens.

the code like this.

    for(int i=0;i<10;i++){
        Thread thread = new Thread(new Runnable() {

            @Override
            public void run() {
                ShardedJedis jedis = TestShard.pool.getResource();
                TestShard.pool.returnResource(jedis);
            }
        });
        thread.start();
    }

jinghong avatar Feb 24 '11 11:02 jinghong

I found the problem appears when using MD5 hashing algorithm, java.lang.ArrayIndexOutOfBoundsException happens, when using Hashing.MURMUR_HASH, all is OK.

jinghong avatar Feb 24 '11 12:02 jinghong

oh! that is a bug. I just ran the code you posted in a test and it worked OK. could you tell me how to reproduce the error with MD5?

xetorthio avatar Feb 24 '11 19:02 xetorthio

construct pool like this pool = new ShardedJedisPool(config, shards); will lead the problem. pool = new ShardedJedisPool(config, shards, Hashing.MURMUR_HASH); is OK.

jinghong avatar Feb 25 '11 03:02 jinghong

I know it's been sometime since this. Made some tests and couldn't reproduce this, even not with your code. There has been some fixes on master, would you mind trying again on master? Sorry about the inconveniences and thanks a lot!

xetorthio avatar Mar 25 '11 14:03 xetorthio

Now it's been even longer! :) Anyway there was a bug in how Jedis used MD5 and now it is fixed in master branch. So I this bug is fixed by fixing the other issue. Thanks a lot!

xetorthio avatar May 12 '11 01:05 xetorthio