Killing active users
Hi:
I have a system where I have 2 DBs. The first is available to the users
for general interaction. The second gets reloaded with new data once
per night and is then "renamed" to the active one if/when the reload
went successfully, preserving the old DB as a standby. Here's a
snapshot of that process.
alter database maindb rename to temp;
alter database standby rename to maindb
alter database temp rename to standby
The problem is that sometimes the rename fails because there are active
users on the available DB... DBD::Pg::db do failed: ERROR: database
"maindb" is being accessed by other users . Because the reload takes
place in the wee hours, I feel it's OK to kill any existing user
connections in order to prevent this if I have to.
Q: Is there a way to kill all active users on a DB without having to
reboot the DB?
Q: Or is my problem moot in that there is a way to leave those
connections alone and attached to the now renamed DB?
Thanks in Advance for any help
-dave
The problem is that sometimes the rename fails because
there are active
users on the available DB... DBD::Pg::db do failed: ERROR:
database
"maindb" is being accessed by other users .
Because the reload takes
place in the wee hours, I feel it's OK to kill any
existing user
connections in order to prevent this if I have to.
You could change ph_hba whilst you rename the databases.
I have a similar case here, where I restore a backup of our main servers onto a "restore" machine that can be used by the developers as a staging environment, but those developers can still be connected.
What I do is have a pg_hba.deny.conf and before I reload the database I rename pg_hba.conf to bg_hba.normal.conf, and pg_hba.deny.conf to pg_hba.conf and restart the server, do my work then put them back and restart the server again. Not sure but you could perhaps even do this with a reload rather than a restart.
Glyn
Send instant messages to your online friends http://uk.messenger.yahoo.com