pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Terminating Idle Connections
3+ messages / 3 participants
[nested] [flat]

* Terminating Idle Connections
@ 2006-05-09 23:29 Chris Hoover <revoohc@gmail.com>
  2006-05-10 08:08 ` Re: Terminating Idle Connections Andy Shellam <andy.shellam@mailnetwork.co.uk>
  2006-05-10 08:32 ` Re: Terminating Idle Connections Uwe C. Schroeder <uwe@oss4u.com>
  0 siblings, 2 replies; 3+ messages in thread

From: Chris Hoover @ 2006-05-09 23:29 UTC (permalink / raw)
  To: pgsql-admin

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

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Terminating Idle Connections
  2006-05-09 23:29 Terminating Idle Connections Chris Hoover <revoohc@gmail.com>
@ 2006-05-10 08:08 ` Andy Shellam <andy.shellam@mailnetwork.co.uk>
  1 sibling, 0 replies; 3+ messages in thread

From: Andy Shellam @ 2006-05-10 08:08 UTC (permalink / raw)
  To: 'Chris Hoover' <revoohc@gmail.com>; +Cc: pgsql-admin

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! 

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Terminating Idle Connections
  2006-05-09 23:29 Terminating Idle Connections Chris Hoover <revoohc@gmail.com>
@ 2006-05-10 08:32 ` Uwe C. Schroeder <uwe@oss4u.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Uwe C. Schroeder @ 2006-05-10 08:32 UTC (permalink / raw)
  To: pgsql-admin; +Cc: Chris Hoover <revoohc@gmail.com>


"idle in transaction" usually means the software using the database has a bug.
Technically it means your software issues a "BEGIN" statement, but never a 
rollback or commit. 
PostgreSQL doesn't provide a way to kill processes that are blocked due to 
programming errors, that would kind of defeat the purpose.
Try to find out what exactly causes this. It's definitely a transaction that 
was started but never ended. Maybe turning on SQL statement logging in 
postgresql.conf can help to find the culprit.



On Tuesday 09 May 2006 16:29, Chris Hoover wrote:
> 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



--
Open Source Solutions 4U, LLC	1618 Kelly St
Phone:  +1 707 568 3056		Santa Rosa, CA 95401
Cell:   +1 650 302 2405		United States
Fax:    +1 707 568 6416



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2006-05-10 08:32 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-05-09 23:29 Terminating Idle Connections Chris Hoover <revoohc@gmail.com>
2006-05-10 08:08 ` Andy Shellam <andy.shellam@mailnetwork.co.uk>
2006-05-10 08:32 ` Uwe C. Schroeder <uwe@oss4u.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox