Help Center> Data Lake Insight> FAQs> Flink Jobs> Flink Jar Jobs> Why Does a Flink Jar Job Fail to Access GaussDB(DWS) and a Message Is Displayed Indicating Too Many Client Connections?
Updated on 2024-01-23 GMT+08:00

Why Does a Flink Jar Job Fail to Access GaussDB(DWS) and a Message Is Displayed Indicating Too Many Client Connections?

Symptom

When a Flink Jar job is submitted to access GaussDB(DWS), an error message is displayed indicating that the job fails to be started. The job log contains the following error information:

FATAL:  Already too many clients, active/non-active/reserved: 5/508/3

Cause Analysis

The number of GaussDB(DWS) 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.

Solution

Perform the following steps to solve the problem:

  1. Log in to the GaussDB(DWS) command window and run the following SQL statement to release all idle (non-active) connections temporarily:
    SELECT PG_TERMINATE_BACKEND(pid) from pg_stat_activity WHERE state='idle';
  2. Check whether the application actively releases the connections. If the application does not, optimize the code to release the connections.
  3. On the GaussDB (DWS) management console, configure 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 this parameter is 600 seconds. The value 0 indicates that the timeout limit is disabled. Do not set session_timeout to 0.

    The procedure for setting parameter session_timeout is as follows:

    1. Log in to the GaussDB(DWS) management console.
    2. In the navigation pane on the left, click Clusters.
    3. In the cluster list, find the target cluster and click its name. The Basic Information page is displayed.
    4. Click the Parameter Modifications tab and modify the value of parameter session_timeout. Then click Save.
    5. In the Modification Preview dialog box, confirm the modification and click Save.

For more information, see An Error Indicating Too Many Client Connections.

Flink Jar Jobs FAQs

more