Tom Lane wrote:
> The DROP is at risk, but CREATE is also at risk because autovac feels
> free to connect to template0. (One of the reasons we invented template0
> was to prevent CREATE DATABASE failures due to someone-else-connected,
> but autovac has broken that idea.)
ALTER DATABASE RENAME also needs the same treatment.
> Possibly we could handle these by extending create/drop db to check
> whether a process-connected-to-the-target-db is an autovac, and if so
> send it a SIGINT and wait for the process to terminate, instead of
> failing.
I'm cooking a patch for this which seems pretty reasonable, but I'm
having a problem: what mechanism do we have for waiting until a process
exits? Maybe make autovacuum acquire an LWLock at start, which it then
keeps until it's gone, but it seems wasteful to have a lwlock just for
that purpose.
Another idea is to do kill(0, AutoVacPID); sleep(); in a loop, but that
seems pretty stupid.
Better ideas anyone?
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.