Re: killing old connections

From: Reiner Dassing <dassing(at)wettzell(dot)ifag(dot)de>
To: Tim White <twhite(at)friendlyworks(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: killing old connections
Date: 2000-06-08 15:05:13
Message-ID: 393FB629.A6DCBAA3@wettzell.ifag.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hello Tim!

Tim White wrote:
>
> Is there a way to view the active/inactive connections to PostgreSQL 6.5.3?

I have the same problems, but I solved it by using the following
algorithm:

1. Get a list all processes of the postmaster by
ps -u postgres | grep /usr/local/pgsql/bin/postmaster

2. If there is just 1 process, finish

3. Determine the pid's (Process IDs) of all the processes of step 1

4. Determine the PPIDs (Parent PIDs) of all processes, by
ps -p PID -o ppid
(well, this line is for Tru64; you have to ask your man page for your
switches)

5. Determine the process which is the father of all your processes,
this is the one which has as its father the PID 1

The father postmaster so to say is not the process you should look at
during the further steps.

6. For all the other PIDs do
- determine the elapsed sleeping time and ist state
by ps -p PID -o etime,sl,state (under Tru64)
- if the sleeping time is greater than ??? hours (or minutes)
kill it by 'kill PID'

This algorithm was implemented in PERL and is running every hour
via cron.

Maybe that helps

> And if so is it possible to kill those that are inactive? I'm having
> difficulty in testing using a Java application, where connections are
> established and then not being destroyed properly. This causes me to get an
> error message stating that there are "...too many clients already.".
>
> Any help is greatly appreciated.
>
> Tim White

--
Mit freundlichen Gruessen / With best regards
Reiner Dassing

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message John Daniels 2000-06-08 15:16:56 FreeBSD PostgreSQL7 port and v7.0.2
Previous Message HENAFF Mari-mai FTRD/DMI/LAN 2000-06-08 14:47:53 accent marks