Re: Clearing out old idle connections - Mailing list pgsql-general

From Ivan Zolotukhin
Subject Re: Clearing out old idle connections
Date
Msg-id 751e56400605240413o462e6d56na820f4746e5b6dda@mail.gmail.com
Whole thread Raw
In response to Clearing out old idle connections  (Gavin Hamill <gdh@laterooms.com>)
List pgsql-general
Hello,

> We have pg 8.1.3 and for whatever reason (network blips, poor pooling on
> behalf of the client, etc.) we sometimes see a large number (dozens) of
> old connections in the idle state which never get reused.

It seems that I have more or less the same problem. Sometimes I see in
`ps aux` lots of idle connections from web application. They disappear
in several minutes but I do not know what the reason of it and how
they disappear. I have statement_timeout by it obviously is not
related with these clients since they are idle.

> Is there a function in postgres similar to MySQL's 'wait_timeout' which
> automatically closes any connections which have been idle for N seconds?
> Is this functionality possible to to script/cron by examining the pg
> catalogs and finding a 'last used' timestamp?

It is possible to find out time of backend start and it's state
through pg_stat_activity view. But I'd prefer not to kill -QUIT these
connections if there's something special for this situation built in
PostgreSQL.

Regards,
Ivan Zolotukhin

pgsql-general by date:

Previous
From: Kenneth Downs
Date:
Subject: Re: challenging constraint situation - how do I make it
Next
From: Rafal Pietrak
Date:
Subject: Re: background triggers?