The title basically says it. Running dropdb
seems to fail if autovacuum is active. I'm currently using vacuumdb --full x && dropdb x
as workaround (I assume that after a full vacuum run no vacuum will be active afterwards if the db is not modified.) However this obviously is not very efficient since I don't need a db which I'm about to delete to be cleaned.
I'm not sure but it seems that autovacuum runs via the postgres
user and thus one could maybe use https://dba.stackexchange.com/questions/11893/force-drop-db-while-others-may-be-connected-in-postgresql to kick it out while vacuum is running.
Still, is there a better/simpler way?
You can stop the postgres instance and start again in single user mode. Insert
--single
as option topostgres
orpg_ctl
command while starting postgres. More to dig here. Please note that You need to connect to another database than the one You want to drop.