X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 49F609F96B6 for ; Wed, 10 May 2006 05:08:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 60584-02 for ; Wed, 10 May 2006 05:08:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sydney.mailnetwork.co.uk (server88-208-192-113.live-servers.net [88.208.192.113]) by postgresql.org (Postfix) with ESMTP id C087C9F931D for ; Wed, 10 May 2006 05:08:35 -0300 (ADT) Received: from [213.146.143.243] (port=6521 helo=it020361) by sydney.mailnetwork.co.uk with esmtpa (Exim 4.60) (envelope-from ) id 1FdjkI-00080Z-D8; Wed, 10 May 2006 09:08:34 +0100 Reply-To: From: "Andy Shellam" To: "'Chris Hoover'" Cc: Subject: Re: Terminating Idle Connections Date: Wed, 10 May 2006 09:08:41 +0100 Organization: the mail network MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002C_01C67411.553F84D0" X-Mailer: Microsoft Office Outlook, Build 11.0.5510 In-reply-to: <1d219a6f0605091629g5651582cxe7e5eeddcc75f765@mail.gmail.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Thread-Index: AcZzwLS/DoBWmnqZRJSrQRZkALNi5wAR73Gg Message-Id: <20060510080835.C087C9F931D@postgresql.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/100 X-Sequence-Number: 21632 This is a multi-part message in MIME format. ------=_NextPart_000_002C_01C67411.553F84D0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Chris, In a shell script, you could do a "ps auxwww|grep 'idle in transaction'" which would give you a list of all processes with a status of "idle in transaction." Then run through each line of the output, use "awk" to find the process id, and issue a "kill " to each process. Obviously this kills all idle in transaction processes, of which some may be genuinely waiting. The best idea would be to see where your idle transactions are coming from, and work out why they're being left idle and not disconnecting (ie. In your app/s.) Better to find the cause of the problem than try and patch it. A "ps auxwww|grep postgres" will show you the host of the connection, the DB it's connect to and the user (as long as this is enabled in your PG config.) Andy _____ From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Chris Hoover Sent: 10 May 2006 12:30 am To: pgsql-admin@postgresql.org Subject: [ADMIN] Terminating Idle Connections Is there a way inside of Postgresql to automatically terminate idle connections? I would like to terminate any connection to my database that has not has any activity for a specified period of time. I would like to be able to do this despite the state of the connection (the majority of my truly idle connections show "idle in transaction" in the process table). I would love for the db engine to do this, but if it can't, is there an easy way to do this outside the database with some sort of script? If this is not possible, would there be a possibility of it being added to a future version? thanks, Chris RH 4.0 AS PostgreSQL 8.1.3 !DSPAM:14,4461265534491787116627! ------=_NextPart_000_002C_01C67411.553F84D0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Chris,

 

In a shell script, you could do a = “ps auxwww|grep ‘idle in transaction’” which would give = you a list of all processes with a status of “idle in = transaction.”  Then run through each line of the output, use “awk” to find the = process id, and issue a “kill <pid>” to each = process.

 

Obviously this kills all idle in transaction processes, of which some may be genuinely = waiting.

 

The best idea would be to see where = your idle transactions are coming from, and work out why they’re being = left idle and not disconnecting (ie. In your app/s.)  Better to find the = cause of the problem than try and patch it.

 

A “ps auxwww|grep = postgres” will show you the host of the connection, the DB it’s connect to = and the user (as long as this is enabled in your PG = config.)


Andy

 


From: pgsql-admin-owner@postgresql.org = [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Chris Hoover
Sent: 10 May 2006 12:30 = am
To: = pgsql-admin@postgresql.org
Subject: [ADMIN] = Terminating Idle Connections

 

Is there a way inside of Postgresql to automatically terminate = idle connections?  I would like to terminate any connection to my = database that has not has any activity for a specified period of time.  I would = like to be able to do this despite the state of the connection (the majority of = my truly idle connections show "idle in transaction" in the = process table).  I would love for the db engine to do this, but if it = can't, is there an easy way to do this outside the database with some sort of = script?

If this is not possible, would there be a possibility of it being added = to a future version?

thanks,

Chris

RH 4.0 AS
PostgreSQL 8.1.3 !DSPAM:14,4461265534491787116627! =

------=_NextPart_000_002C_01C67411.553F84D0--