首页 函数计算(旧版) 服务支持 常见问题 代码开发FAQ Java运行环境FAQ 使用Jedis连接池模式报错Could not get a resource from the pool如何解决?

使用Jedis连接池模式报错Could not get a resource from the pool如何解决?

更新时间: 2023-04-10 13:13:59

本文介绍报错Could not get a resource from the pool的原因和解决方案。

问题现象

使用Java运行环境Jedis连接池模式遇到报错Could not get a resource from the pool

可能原因

  • Redis白名单配置错误。

  • 其他错误。

解决方案

首先,在Cause Exception日志中找到以Caused by:开头的日志,然后根据日志进行分析。示例日志如下:

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
  ....
Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR client ip is not in whitelist xxx:xxx
说明

使用getStackTrace()无法打印出Caused by:日志,需要直接输出exception或者使用getCause()方法打印。

ERR client ip is not in whitelist xxx:xxx

Redis白名单配置错误,需重新配置白名单。具体操作,请参见步骤一:配置数据库访问IP地址白名单

重要

如果该报错是偶然现象,请检查是否使用了安全组的方式访问数据库。安全组方式会导致函数连接不稳定,影响业务正常运行,建议改为IP地址白名单方式。

其他报错

如果遇到其他报错,例如Timeout waiting for idle objectPool exhausted,请参见云数据库Redis的以下文档进行排查。

阿里云首页 函数计算(旧版) 相关技术圈