Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2010
    Location
    Orlando, FL
    Posts
    311
    Provided Answers: 1

    Question Unanswered: 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?

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •