'Could not get a resource from the pool' when using ShardedJedisPool
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();
}
I found the problem appears when using MD5 hashing algorithm, java.lang.ArrayIndexOutOfBoundsException happens, when using Hashing.MURMUR_HASH, all is OK.
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?
construct pool like this pool = new ShardedJedisPool(config, shards); will lead the problem. pool = new ShardedJedisPool(config, shards, Hashing.MURMUR_HASH); is OK.
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!
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!