Re: Manually clearing "database "foo" is being accessed by other users"

From: Madison Kelly <linux(at)alteeve(dot)com>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Manually clearing "database "foo" is being accessed by other users"
Date: 2007-09-25 20:28:47
Message-ID: 46F96F7F.8010701@alteeve.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Steve Crawford wrote:
> Sysadmin wrote:
>> Hi all,
>>
>> I'm finding that routinely when I try to reload a database on a server
>> where I know there are no connections to a given DB I get the error:
>>
>> $ dropdb foo && createdb foo -O bar && psql foo -f /path/to/db.out
>> dropdb: database removal failed: ERROR: database "foo" is being
>> accessed by other users
>>
>> This means I need to restart the postmaster, but the server contains
>> many DBs, of which some may actually be in use. How can I tell postgres
>> that the database 'foo' should be marked as not in use / clear or drop
>> any open connections / etc?
>
> If you connect to "foo" and run "select * from pg_stat_activity;" what
> does it show?
>
> Have you tried changing pg_hba.conf (and reloading PG and waiting for
> current connections to terminate of course) to deny access to foo before
> running your commands?
>
> Is there a pg_dumpall (or anything else that might access that db at the
> PG superuser level) running at the time?
>
> Cheers,
> Steve

Thanks, Steve!

Turns out a daemon was indeed still connected to the database... that
command pointed that out, and I assure you I gave myself a decent smack
in the forehead for it. :)

Madi

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-09-25 21:23:58 Re: cascade and restrict options to alter domain drop constraint
Previous Message Morris Goldstein 2007-09-25 20:17:25 Re: Can't connect (2 dbs) or login (2 others)