Re: Clearing out old idle connections

From: "Ivan Zolotukhin" <ivan(dot)zolotukhin(at)gmail(dot)com>
To: "Gavin Hamill" <gdh(at)laterooms(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Clearing out old idle connections
Date: 2006-05-24 11:13:50
Message-ID: 751e56400605240413o462e6d56na820f4746e5b6dda@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rafal Pietrak 2006-05-24 11:31:32 Re: background triggers?
Previous Message Kenneth Downs 2006-05-24 11:00:04 Re: challenging constraint situation - how do I make it