Safe to kill idle connections?

Started by Francisco Reyesover 20 years ago4 messagesgeneral
Jump to latest
#1Francisco Reyes
lists@natserv.com

Ever since I installed a particular program, PHPWiki, I am seeing idle
postgres sessions.. even days old. Is it safe to delete them?

For example:
postmaster: wiki simplicato_wiki [local] idle (postgres)

Ultimately I will either switch wiki or take the time and find the piece
of code that is causing the sessions to remain open, but until then don't
want to leave those idle sessions around.. for days.

#2Thomas Beutin
tb@laokoon.in-berlin.de
In reply to: Francisco Reyes (#1)
Re: Safe to kill idle connections?

Francisco Reyes wrote:

Ever since I installed a particular program, PHPWiki, I am seeing idle
postgres sessions.. even days old. Is it safe to delete them?

I wouln't do that. These seems to be php persistent connections, and
they are idle for the moment but reused for new wiki requests.
http://www.php.net/pg_pconnect

For example:
postmaster: wiki simplicato_wiki [local] idle (postgres)

Ultimately I will either switch wiki or take the time and find the piece
of code that is causing the sessions to remain open, but until then
don't want to leave those idle sessions around.. for days.

If there is no configuration switch, search for pg_pconnect in the code
and replace it with pg_connect, but if You're running a site with heavy
traffic i recommend to use the persistent connections for performance
reasons.

Cheers,
-tb
--
Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

#3Richard Huxton
dev@archonet.com
In reply to: Francisco Reyes (#1)
Re: Safe to kill idle connections?

Francisco Reyes wrote:

Ever since I installed a particular program, PHPWiki, I am seeing idle
postgres sessions.. even days old. Is it safe to delete them?

For example:
postmaster: wiki simplicato_wiki [local] idle (postgres)

Ultimately I will either switch wiki or take the time and find the piece
of code that is causing the sessions to remain open, but until then
don't want to leave those idle sessions around.. for days.

At a guess, PHPWiki is using persistent connections to PG, so you'll get
one connection per Apache backend. If you reduce the number of idle
Apache backends you should reduce the number of idle PG connections too.
Alternatively, a small change in PHPWiki's code should clear it too
(start with a search for pg_pconnect and try pg_connect instead).

It's perfectly safe to leave the idle connections there - they won't
take up much in the way of resources.

HTH
--
Richard Huxton
Archonet Ltd

#4Richard Huxton
dev@archonet.com
In reply to: Francisco Reyes (#1)
Re: Safe to kill idle connections?

Francisco Reyes wrote:

How about when one needs to reload to read new postgresql.conf files.
Will iddle connections prevent the server from reloading?

http://www.postgresql.org/docs/8.0/static/app-pg-ctl.html

Also, in the future if other programs do the same, is it safe to kill
these and if so what is the best way? kill command?

The pg_ctl program handles all your start/stop/reload requirements,
although it just packages up various "kill" commands internally AFAIK.
Probably a good idea to use it, since it gives you cross-platform
compatibility for these things.
--
Richard Huxton
Archonet Ltd