如何在jedispool中设置废弃配置-jedisexhaustedpoolexception错误

6vl6ewon  于 2021-06-09  发布在  Redis
关注(0)|答案(0)|浏览(261)

我面临着一个类似于绝地1929年的问题。我们用的是 maxTotal=400 确保在使用了 pool.getResource() 我们正在将连接返回到池中 finally 阻止使用 jedis.close() 方法。绝地版本是 3.0.0 . 该问题在连续运行程序几天后出现。我们正在redis中获取/设置每分钟约0.1m次的键值对。键和值都非常小,值约为120字节。用例的阅读量很大。
想要设置AbundConfig以确保在默认超时后关闭泄漏的连接,但没有找到为Spool设置AbundConfig相关设置的方法。下面是我们得到的例外,当numactions等于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

以下是我们的配置:

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

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题