User Backend Sessions

Started by Carl Olivierabout 23 years ago2 messagesgeneral
Jump to latest
#1Carl Olivier
carl@zero-one.co.za

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

#2Carl Olivier
carl@zero-one.co.za
In reply to: Carl Olivier (#1)
Re: User Backend Sessions

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