文档首页> 云数据库 GeminiDB> GeminiDB Redis接口> 常见问题> 数据库连接> 如何处理客户端连接池报错“Could not get a resource from the pool”
更新时间:2024-04-12 GMT+08:00
分享

如何处理客户端连接池报错“Could not get a resource from the pool”

报错场景

客户端业务发现大量GeminiDB请求卡住,异常堆栈中出现如下报错信息:
  • Jedis客户端:
    redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
  • Lettuce客户端:
    redis.connection.lettuce.LettucePoolingConnectionProvider.getConnection
  • Go-redis客户端:
    redis: connection pool timeout
    You can get that error when there are no free connections in the pool for Options.PoolTimeout duration. If you are using redis.PubSub or redis.Conn, make sure to properly release PuSub/Conn resources by calling Close method when they are not needed any more.
    You can also get that error when Redis processes commands too slowly and all connections in the pool are blocked for more than PoolTimeout duration.

但是通过查看实例的监控指标信息,发现数据库QPS、时延、连接数等信息一切正常,无慢请求信息。

报错可能原因

上述问题一般为客户端连接池配置问题。对于使用连接池的应用来说,连接池是有最大数量限制的。如果业务所使用QPS超过连接池的承受限制,或者没有及时释放导致连接泄露耗尽,线程就无法获取新的连接而影响业务。

解决方法

通过客户端排查过去2小时内QPS、流量指标是否异常激增,以及使用的Redis客户端(Jedis、Lettuce等)配置的连接池参数是否满足业务需求。

Redis客户端使用配置请参考开发运维规范客户端连接池参数配置

分享:

    相关文档

    相关产品