Re: dropdb: database removal failed: active sessions

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: John R Pierce <pierce(at)hogranch(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: dropdb: database removal failed: active sessions
Date: 2011-08-29 21:17:56
Message-ID: CAOR=d=23rE6=BNPetxfmWJmLGYAYxXqjUnwbhjJH-Nvp=LbQ5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Aug 29, 2011 at 2:39 PM, John R Pierce <pierce(at)hogranch(dot)com> wrote:
> any connection to the database, even idle, will prevent a drop database.
>
> try...
>
>    select pg_terminate_backend(procpid) from pg_stat_activity where datname
> = 'database1';
>
> that will snuff those processes.  then you can drop the database, assuming
> the clients don't immediately reconnect.

If you lose your connection at this point you'll know who was
connected to that database as well.

Yes, I have done that before.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2011-08-29 21:24:19 Re: heavy swapping, not sure why
Previous Message Lonni J Friedman 2011-08-29 20:57:34 Re: heavy swapping, not sure why