Re: Manually clearing "database "foo" is being accessed by other users" - Mailing list pgsql-general

From Tom Lane
Subject Re: Manually clearing "database "foo" is being accessed by other users"
Date
Msg-id 29559.1190316420@sss.pgh.pa.us
Whole thread Raw
In response to Manually clearing "database "foo" is being accessed by other users"  (Sysadmin <linux@alteeve.com>)
Responses Re: Manually clearing "database "foo" is being accessed by other users"  (Sysadmin <linux@alteeve.com>)
List pgsql-general
Sysadmin <linux@alteeve.com> writes:
>   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

If it says there are other connections, then there really are other
connections --- there are not any known bugs in that logic.

What I am wondering though is whether you are allowing for the nonzero
exit time of a backend process.  If the above is part of a script that
was just doing something in database foo, then the drop could fail
because the backend that was serving that session is still cleaning up.
The quickest solution is a 'sleep 1' (or so) before the dropdb.

(FWIW, 8.3 will have some delay built in here to help mask this issue.)

            regards, tom lane

pgsql-general by date:

Previous
From: "madhtr"
Date:
Subject: Re: How to clear bits?
Next
From: Steve Crawford
Date:
Subject: Re: Manually clearing "database "foo" is being accessed by other users"