赞
踩
目录
- org.postgresql.util.PSQLException: FATAL: sorry, too many clients already
- at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:463)
- at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:203)
- at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
- at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
- at org.postgresql.Driver.makeConnection(Driver.java:454)
pg数据库已经有太多的客户端连接
查询pg数据库设置的最大连接数
show max_connections;
SELECT * FROM pg_settings WHERE name = 'max_connections';
查询pg数据库当前的连接数
--pg数据库当前连接数总数
SELECT sum(numbackends) FROM pg_stat_database;
---pg各个数据库中的连接数
SELECT datname, numbackends FROM pg_stat_database;
查询pg某个数据库某个ip的连接数
SELECT datname,pid,state FROM pg_stat_activity where datname = 'zwzt' and client_addr='192.168.100.88';
关闭数据库中的空闲连接
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity WHERE pg_stat_activity.datname = 'zwzt'and client_addr='192.168.100.88' and state='idle'
and pid <> pg_backend_pid();
当前数据库中的连接数1993,然而pg数据库设置的最大连接数是2000
pg数据库的最大连接数
因此项目启动中很容易就超过了2000.
我把我ip连接的pg的空闲进程的连接都杀掉,再次启动就好了
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = 'zwzt' and client_addr='192.168.100.88' and state='idle'
AND pid <> pg_backend_pid();
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。