Re: Thorsten Glaser 2014-07-24 
<[email protected]>
> postgres=# DROP DATABASE simkolab;
> ERROR:  database "simkolab" is being accessed by other users
> DETAIL:  There is 1 other session using the database.
> 
> Some related reading:
> - http://stackoverflow.com/a/5109190/2171120
> - http://stackoverflow.com/a/7489673/2171120
> 
> The reason here is that Apache has not yet been restarted/reloaded
> and that one of its children is holding the connection open.
> 
> I’m currently trying to shuffle the dbc_go call in postrm in
> between do_webserver_config() / apache2_invoke disconf and the
> rest of the cleanup, but that means duplicating it, etc.
> 
> It would be really nice if dbconfig-common could be patched to
> tear down a database using the method shown in the above SO link:
> 
> 1) REVOKE CONNECT ON DATABASE dbname FROM PUBLIC, username;
> 2) SELECT
>     pg_terminate_backend(procpid)
>    FROM
>     pg_stat_activity
>    WHERE
>     -- don't kill my own connection!
>     procpid <> pg_backend_pid()
>     -- don't kill the connections to other databases
>     AND datname = 'database_name'
>    ; -- for psql 8.4 to 9.1
>      -- in psql 9.2 the column procpid was renamed to pid
> 3) DROP DATABASE dbname;
> 
> Might be useful to have the psql maintainers say something to
> this as well; perhaps there’s an easier way?

That's about the best you can do from the DB side.

Christoph
-- 
[email protected] | http://www.df7cb.de/


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to