Jedis Pool acting up weird

514 views
Skip to first unread message

Ori S

unread,
Dec 2, 2016, 5:20:38 AM12/2/16
to Jedis
Hi,

Facing a rather weird situation where, occasionally, when I want to get a connection from the Jedis pool using pool.getResource(), I have a timeout. This happens sporadically and I cannot pinpoint the cause.

The following static function configures a pool which later is used throughout the app:

public static JedisPool getJedisPool(int db) {
   
JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig
.setBlockWhenExhausted(true);
    poolConfig
.setTimeBetweenEvictionRunsMillis(10000);
    poolConfig
.setMinIdle(1);
    poolConfig
.setMaxIdle(3);
    poolConfig
.setMaxTotal(5);
   
return new JedisPool(poolConfig, "127.0.0.1", 6363, 5000, "", db);
}


It's also important to note that both the Java app and the Redis server run on the loopback device and iptables allows traffic to pass there unhindered.

The following times out occasionally and I cannot find out why:

Jedis redis = null;
try {
   
// "pool" is obtained early in the app by calling getJedisPool(int).
   
// This call is failing:
    redis
= pool.getResource();


   
// Work with redis.
   
...
} finally {
   
if(null != redis) {
        redis
.close();
        redis
= null;
   
}
}


Trace of an error:

java.util.NoSuchElementException: Timeout waiting for idle object
 at org
.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:449)
 at org
.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
 at redis
.clients.util.Pool.getResource(Pool.java:49)
 at redis
.clients.jedis.JedisPool.getResource(JedisPool.java:226)
       
...
 at java
.lang.Thread.run(Thread.java:745)


Versions of libraries and binaries used:

CentOS Linux 3.10.0-327 x86_64
Java(TM) SE build 1.8.0_65-b17
Jedis 2.9.0
Redis 3.0.7

Any help is appreciated. Thanks in advance.

/OS

Azilet Beishenaliev

unread,
Dec 15, 2016, 6:45:34 AM12/15/16
to Jedis

Hi Ori,

This case is not weird taking into account that you have configured your Jedis pool to use maximum of 5 connections. Most probably your application is reaching this limit and still you are trying to get a connection from the pool.

You better increase your max connections count. In current state of the Jedis it is 8 by default.



Jordi Gerona

unread,
Dec 17, 2016, 1:07:49 PM12/17/16
to Jedis

Hi Ori,

I would also recommend setting Redis server timeout to 0. In my case, this made to go away all timeout errors

Best,
jordi


--
You received this message because you are subscribed to the Google Groups "Jedis" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jedis_redis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages