0

I am facing an issue similar to the one jedis-1929. We are using JedisPool with maxTotal=400 and have ensured that after using jedis from pool.getResource() we are returning the connection back to the pool in finally block using jedis.close() method. Version of jedis is 3.0.0. The issue appears after continuously running the program for several days. We are getting/setting key-value pair in Redis around 0.1m times per minute. The key and values are both quite small, values approx 120 bytes. Use-case is mostly read heavy.

Wanted to set AbandonConfig to ensure leaked connections if any get closed after a default timeout, but don't see a way to set AbandonConfig related settings for JedisPool. Following is the exception we get, when numActives become equal to maxTotal

redis.clients.jedis.exceptions.JedisExhaustedPoolException: Could not get a resource since the pool is exhausted
        at redis.clients.jedis.util.Pool.getResource(Pool.java:53)
        at redis.clients.jedis.JedisPool.getResource(JedisPool.java:234)
        at com.til.ibeat.connection.RedisConnection.getconnection(RedisConnection.java:52)
        at com.til.ibeat.service.impl.RedisCacheServiceImpl.pushToRedisSet(RedisCacheServiceImpl.java:188)
        at com.til.ibeat.service.impl.MessageEnrichService.getVisitorType(MessageEnrichService.java:541)
        at com.til.ibeat.service.impl.MessageEnrichService.populateVisitorType(MessageEnrichService.java:439)
        at com.til.ibeat.service.impl.IbeatEventLogService.process(IbeatEventLogService.java:111)
        at com.til.ibeat.service.impl.IbeatEventLogService$2.call(IbeatEventLogService.java:70)
        at com.til.ibeat.service.impl.IbeatEventLogService$2.call(IbeatEventLogService.java:67)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.util.NoSuchElementException: Pool exhausted
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:452)
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:361)
        at redis.clients.jedis.util.Pool.getResource(Pool.java:50)
        ... 12 common frames omitted

Following is our configuration:

    <bean id="redisPool2" class="redis.clients.jedis.JedisPool">
        <constructor-arg index="0" type="org.apache.commons.pool2.impl.GenericObjectPoolConfig" ref="poolConfig2"/>
        <constructor-arg index="1" type="java.lang.String" value="${jedis2.host}" />
        <constructor-arg index="2" type="int" value="${jedis2.port:6379}"/>
        <constructor-arg index="3" type="int" value="${jedis2.timeout.millis:200}"/>
        <constructor-arg index="4" type="java.lang.String" value="${jedis2.password}" />
    </bean>
    <bean id="poolConfig2" class="org.apache.commons.pool2.impl.GenericObjectPoolConfig">
        <property name="maxTotal" value="${jedis2.max.total:-1}" />
        <property name="maxIdle" value="${jedis2.max.idle:50}" />
        <property name="minIdle" value="${jedis2.min.idle:3}" />
        <property name="testOnBorrow" value="${jedis2.test.on.borrow:true}" />
        <property name="testOnReturn" value="${jedis2.test.on.return:false}" />
        <property name="testWhileIdle" value="${jedis2.test.while.idle:false}" />
        <property name="minEvictableIdleTimeMillis" value="${jedis2.min.evictable.idle.time.millis:2000}" />
        <property name="timeBetweenEvictionRunsMillis" value="${jedis2.time.between.eviction.runs:30000}" />
        <property name="numTestsPerEvictionRun" value="${jedis2.tests.per.eviction.run:10}" />
        <property name="blockWhenExhausted" value="${jedis2.block.when.exhausted:false}" />
        <property name="jmxEnabled" value="${jedis2.jmx.enabled:true}"/>
        <property name="jmxNamePrefix" value="${jedis2.host}"/>
    </bean>
Pankaj Yadav
  • 139
  • 1
  • 10
  • Hi Pankaj. Did you find a solution for this? – Arbaz Sheikh Dec 08 '20 at 11:59
  • @ArbazSheikh - no. Will have to create own wrappers if we want to achieve this. – Pankaj Yadav Dec 08 '20 at 13:52
  • 1
    I am also returning the connection back to the pool in finally block using jedis.close() method. Did you find the exact reason for this kind of error – Arbaz Sheikh Dec 08 '20 at 14:22
  • This was already reported here [#2050](https://github.com/redis/jedis/issues/2050) and also a PR was raised [#2054](https://github.com/redis/jedis/pull/2054) .. but did not make it to merge... – Pankaj Yadav Jan 27 '21 at 12:37

0 Answers0