Postgres 9.1 sever is running under Debian. It is accessed by Mono MVC4 web applications using ngpsql, Apache and mod_mono. It is also accessed by pg_dump in same computer every night and from 5432 port from internet. Connections were cleared at June 20. pgAdmin statuc window shows lot of idle connections starting from this day. (see image below).
After some time number of connections goes to 100 and server stops to accept connections. Connections needs to be manually killed in pgAdmin. Only after that server start accepting connections again.
It is interesting that start times of some of those connections are exactly the same as shown in image.
How to fix or diagnose the issue ?
I tried /etc/init.d/apache2 restart
. This closed 25 and 27 June connections but 20 June connections are still open.
How to close idle connections automatically or find the reason of open connections ? Maybe there is some postgres or Debian setting which closes idle connections automatically ?
Using
"PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu, compiled by gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 64-bit"
Update
Application uses the following connection string:
NpgsqlConnectionStringBuilder csb = new NpgsqlConnectionStringBuilder()
{
SearchPath = schema == null ? "public" : schema + ",public",
Timeout = 115,
CommandTimeout = 115,
Host = Config.Server,
Database = Config.DefaultDataBase,
UserName = Config.ServerUser,
Port = Config.Port,
// Apache allows 150 connections, MaxPoolSize is set accordingly:
MaxPoolSize = 155
};