All Products
Search
Document Center

ApsaraDB RDS:What do I do if excessive connections are established on an ApsaraDB RDS for PostgreSQL instance?

Last Updated:Dec 11, 2023

If excessive connections are established on an ApsaraDB RDS for PostgreSQL instance, clients cannot connect to the RDS instance. You can view the maximum number of connections that are allowed for the RDS instance and close unnecessary connections.

Problem description

The number of connections to an RDS instance reaches the upper limit, and clients cannot connect to the RDS instance. The following error message is displayed:

FATAL: remaining connection slots are reserved for non-replication superuser connections

Solutions

If some session windows remain, perform the following steps to terminate the connection processes in the remaining session windows.

  1. Choose SQL Operations > SQL Window. Execute the following SQL statement to check the maximum number of connections that are allowed for your RDS instance.

    show max_connections;
  2. Execute the following SQL statement to view the number of current connections and record the progress IDs (PIDs) of the connections that you want to close.

    select * from pg_stat_activity;
  3. Execute the following SQL statement to terminate the connection process.

    SELECT pg_terminate_backend([$PID]) FROM pg_stat_activity;
    Note

    [$PID] indicates the PID recorded in the preceding step.

Application scope

  • ApsaraDB RDS for PostgreSQL