Обсуждение: killing old connections

Поиск
Список
Период
Сортировка

killing old connections

От
"Tim White"
Дата:
Is there a way to view the active/inactive connections to PostgreSQL 6.5.3?
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


Re: killing old connections

От
Joshua Leshan
Дата:
Did you get an answer to this?

If you are on a unix machine you can check the processes (using ps)
 and then grep for pgsql or the postgres user.

Once you have that list, you can kill the individual processes (if you have
the proper permissions).

Jd

On Tue, 6 Jun 2000, Tim White wrote:

> Is there a way to view the active/inactive connections to PostgreSQL 6.5.3?
> 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
>


Re: killing old connections

От
Reiner Dassing
Дата:
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