Re: User Backend Sessions - Mailing list pgsql-general

From Carl Olivier
Subject Re: User Backend Sessions
Date
Msg-id BCEKIKAMLDKFEKBNELFKEEMNCGAA.carl@zero-one.co.za
Whole thread Raw
In response to User Backend Sessions  ("Carl Olivier" <carl@zero-one.co.za>)
List pgsql-general
OK, so let me ask this question a different way...
 
If you needed to DROP a database via JDBC (or other interface) where there could POTENTIALLY be active sessions (backends) on the specified databases, as well as OTHER databases active on the server where the specified database (i.e. you cannot shot the db (PSql) server down)...
 
HOW would YOU do it??
 
PLEASE help!  So stuck!!
 
;(
 
Thanks,
 
Carl
-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Carl Olivier
Sent: 07 March 2003 01:18 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] User Backend Sessions
Importance: High

Greetings.
 
OK, I am having a problem, and it is driving me mad!
 
I want to kill off active sessions for a specific database.
 
Now, I have installed PSQL with PL/PERL support and have created a function that allows PSQL to run shell commands.
 
So, from here I can use Sql to get a list of the procpids for backends active for a specific database.
 
now, kill -9 is obviously NOT the best idea to use (i.e. to manually and brute force-like kill the postmaster processes for the backends identified).
 
What other methods are there for me to use?
 
After the backends have been killed, I wish to call the DROP DATABASE dbname command via SQL - which does not work unless no sessions are active for the DB.
 
Can anyone assist me here?  Is there a "clean" way to kill of the connections, even if I need to wait for them to finish their tasks then shut down, so that I can safely call DROP DATABASE?!
 
Please help!
 
Thanks in advance,
 
Carl
 
 

pgsql-general by date:

Previous
From: "Cristian Custodio"
Date:
Subject: coerce_type: no conversion function from "unknown type" to text
Next
From: Bruce Momjian
Date:
Subject: Re: My contract has been renewed