Pivotal Knowledge Base

Follow

PgBouncer not able to terminate idle connections

Environment

Product Version
Pivotal Greenplum (GPDB) 4.3.x
PgBouncer 1.6.x and above

Overview

PgBouncer is a connection pooler. Any target application can be connected to PgBouncer as if it were a Greenplum server, and PgBouncer will create a connection to the actual server, or it will reuse one of its existing connections.

The aim of PgBouncer is to lower the performance impact of opening new connections to Greenplum.

The life of the server connections and client connections are controlled by the parameters listed below:

server_idle_timeout

If a server connection has been idle more than the time (seconds) set by this parameter, it will be dropped. If it is 0, then timeout is disabled.

client_idle_timeout

Client connections idling longer than the time (seconds) set by this parameter are closed. 

Symptom

Sometimes PgBouncer does not clean up idle connections even if server_idle_timeout and client_idle_timeout reach their limit.

Cause

There is another parameter that affects this behavior. This comes into effect from PgBouncer version 1.6.x and above. 

min_pool_size: This parameter adds more server connections to the pool if the connections are below this number. This improves behaviour when the usual load comes back suddenly after a period of total inactivity. The default is 0 (disabled).

From PgBouncer versions 1.6.x above, the PgBouncer application disables server_idle_timeout when the server count gets below the min_pool_size.

Resolution

Altering the value of min_pool_size and setting it according to the environment requirements helps in resolving this issue. 

Additional Information

For more information on PgBouncer, please refer to the following:

Comments

Powered by Zendesk