If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > Force Kill Database Connections

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-09-11, 11:31
CarlosinFL CarlosinFL is offline
Registered User
 
Join Date: Oct 2010
Location: Orlando, FL
Posts: 184
Question Force Kill Database Connections

I'm looking for a way to kill all existing connections to a database I messed up. I'm attempting to kill a specific database in PostgreSQL 9.1 & I'm getting the following error:

Code:
postgres=# DROP DATABASE calendar;
ERROR:  database "calendar" is being accessed by other users
DETAIL:  There are 6 other session(s) using the database.
Is there a correct manner in which I should be killing these zombie connections? Nobody should be connected to this database server but me. I think these are orphaned connections from a web browser attempting to initialize the database via a web installer for a calendar application.

Can someone please explain how I can successfully blast / remove this database from my cluster?
Reply With Quote
  #2 (permalink)  
Old 11-09-11, 11:51
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Quote:
Originally Posted by CarlosinFL View Post
Is there a correct manner in which I should be killing these zombie connections?
Use select * from pg_stat_activity to find the open connections. Then use pg_terminate_backend() to kill them.

See:
http://www.postgresql.org/docs/curre...ons-admin.html
http://www.postgresql.org/docs/curre...ing-stats.html
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On