JedisConnectionException: Could not get a resource from the pool -------无法从连接池中获取到连接(资源)。
具体原因主要看Caused By子句。
下面Caused by可知,在调用borrowObject获取idle连接时,由于池中没有idle连接,出现阻塞等待,结果发生等待超时。
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool … Caused by: java.util.NoSuchElementException: Timeout waiting for idle object at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:449)
下面Caused by可知,同样在从池中获取idle连接时,由于池中没有idle连接,并且设置了不等待(blockWhenExhausted=false),故出现异常。
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool … Caused by: java.util.NoSuchElementException: Pool exhausted at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:464)
而我们的优付trans今天出现了如下Caused by的异常--- Pool not open。
2022-12-12 10:09:10.080 WARN [clientBusiness_common_1670810950078S930,TID:d09088df43334542893d6ffc06399ff6.132.16708109500416701,0308d204b0a94d8eb6dd1b48ae72bcec] com.yft.opencommon.cache.JedisUtils:854 :getResource. redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool at redis.clients.util.Pool.getResource(Pool.java:53) at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226) at com.yft.opencommon.cache.JedisUtils.getResource(JedisUtils.java:851) at com.yft.opencommon.cache.JedisUtils.get(JedisUtils.java:53) at com.cn.yft.cache.RedisCacheUtil.getMerReqLimit(RedisCacheUtil.java:213) … Caused by: java.lang.IllegalStateException: Pool not open at org.apache.commons.pool2.impl.BaseGenericObjectPool.assertOpen(BaseGenericObjectPool.java:759) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:395) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:346) at redis.clients.util.Pool.getResource(Pool.java:49) ... 76 common frames omitted
持续时间从上午10:09:10.080~10:17:00.306,影响部分客户下发。运营反馈后,立即重启服务暂时得到解决。
排查:
优付trans有4个节点做负载:两台在自建机房、两台在联通云机房。只有5号节点出现这个异常,其他节点未发现jedis异常。
抛出Pool not open异常的源码在commons-pool2的BaseGenericObjectPool里
/** * Verifies that the pool is open. * @throws IllegalStateException if the pool is closed. */ final void assertOpen() throws IllegalStateException { if (isClosed()) { throw new IllegalStateException("Pool not open"); } }
分析最大原因应该是连接问题, 即,redis服务器与5号节点通信出现不正常,导致JedisPool关闭了。日后继续详细分析。
关于Pool not open异常,网上这篇技术贴写的不错。JedisPool 在关闭情况下为什么 还能提供连接资源 并且 只有一个线程一直拿不到连接资源
微信公众号里也发现一篇文章,https://mp.weixin.qq.com/s/EWH-buDjBthxH6UGrFdP1w 列举jedis常见问题及redis缓存使用规范,值得读。
标签:GenericObjectPool,java,get,Could,redis,pool,resource,Pool From: https://www.cnblogs.com/buguge/p/16977131.html