An Error Indicating Too Many Client Connections Is Reported When a User Connects to a GaussDB(DWS) Database
Symptom
An error indicating too many client connections is reported when a user connects to a GaussDB(DWS) database.
- When a user uses an SQL client tool, such as gsql, to connect to a database, the following error information is displayed:
1FATAL: Already too many clients, active/non-active/reserved: 5/508/3.
- When the user uses multiple clients to concurrently connect to the database, the following error information is displayed:
1 2
[2019/12/25 08:30:35] [ERROR] ERROR: pooler: failed to create connections in parallel mode for thread 140530192938752, Error Message: FATAL: dn_6001_6002: Too many clients already, active/non-active: 468/63. FATAL: dn_6001_6002: Too many clients already, active/non-active: 468/63.
Possible Causes
- The number of current database connections exceeds the upper limit.
In the error information, the value of non-active indicates the number of idle connections. For example, if the value of non-active is 508, there are 508 idle connections.
- The upper limit of connections is set when the user is created.
If the number of connections does not reach the upper limit, the possible cause is that the maximum number of connections is set when the user is created.
Handling Procedure
To resolve this problem, perform the following steps:
- Release all non-active connections temporarily.
1SELECT PG_TERMINATE_BACKEND(pid) from pg_stat_activity WHERE state='idle';
- Check whether the application does not actively release the connections. In this case, optimize the code to release the connections properly.
- On the GaussDB(DWS) management console, set parameter session_timeout, which controls the timeout period of idle sessions. After an idle session's timeout period exceeds the specified value, the server automatically closes the connection.
The default value of parameter session_timeout is 600 seconds. The value 0 indicates that the timeout limit is disabled. You are not advised to set session_timeout to 0.
The procedure for setting parameter session_timeout is as follows:
- Log in to the GaussDB(DWS) management console.
- In the navigation tree on the left, click Cluster Management.
- In the cluster list, find the target cluster and click its name. The Basic Information page is displayed.
- Click the Parameter Modifications tab and modify the value of parameter session_timeout. Then click Save.
- In the Modification Preview dialog box, confirm the modification and click Save.
- If the current maximum number of connections cannot meet service requirements, you can change the value of max_connections on the management console.
For details about how to set max_connections, see 3.
On the management console, choose Basic Information, click the Parameter Modification tab, change the value of max_connections, and click Save.

Last Article: Database Cannot Be Connected Using the gsql Client
Next Article: Cluster IP Address Cannot Be Pinged/Accessed
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.