Help Center/ GeminiDB/ GeminiDB Redis API/ FAQs/ Database Connection/ What Should I Do If the Client Connection Pool Reports Error " Could not get a resource from the pool"?
Updated on 2024-08-06 GMT+08:00

What Should I Do If the Client Connection Pool Reports Error " Could not get a resource from the pool"?

Scenarios

A large number of GeminiDB Redis instance requests are suspended on the clients, and the following error is displayed in the abnormal stack:
  • Jedis client:
    redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
  • Lettuce client:
    redis.connection.lettuce.LettucePoolingConnectionProvider.getConnection
  • Go-redis client:
    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.

However, the instance information queried by following Viewing Monitoring Metrics shows that the database QPS, latency, and number of connections are normal and no slow request is displayed.

Possible Causes

Generally, the preceding issue is caused by incorrect configurations of a client connection pool. The maximum number of the connection pools is limited for applications. If the QPS of an application exceeds the limit of the connection pool or connections are not released in time, the thread cannot obtain new connections and services are affected.

Solution

Check whether the QPS and traffic metrics increase sharply last two hours and whether connection pool parameters configured on the Redis clients (such as Jedis and Lettuce) meet service requirements.

For details about how to configure the Redis clients, see Development and O&M Rules and Configuring Parameters for a Client Connection Pool.