"FATAL: sorry, too many clients already" Displayed When Loading Data for Initialization During PostgreSQL Test
Symptom
During the PostgreSQL test, when a large amount of data is loaded during initialization, for example, when 500 warehouses data is loaded, the message "ERROR: FATAL: sorry, too many clients already" is displayed.

Key Process and Cause Analysis
The amount of loaded data is greater than the value of max_connections in the postgresql.conf file.
Conclusion and Solution
To solve this problem, increase the values of max_connection and idle_in_transaction_session_timeout in the postgresql.conf file.
- Open the postgresql.conf file.
vim /data/pgsql/postgresql.conf
- Press i to enter the insert mode and modify line 64 as follows:
max_connections = 4096
Modify line 574 as follows:
idle_in_transaction_session_timeout = 20000
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Restart the database for the modification to take effect.
/usr/local/pgsql/bin/pg_ctl -D /data/pgsql -l logfile restart
Modify the following directories as required:
- /usr/local/pgsql/bin/pg_ctl is the installation directory of the PostgreSQL program.
- /data/pgsql is the data directory of the PostgreSQL database.
Parent topic: Troubleshooting