Re: Autovacuum improvements - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Autovacuum improvements
Date
Msg-id 20070115145652.GM7233@alvh.no-ip.org
Whole thread Raw
In response to Re: Autovacuum improvements  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Autovacuum improvements
List pgsql-hackers
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.


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: xml type and encodings
Next
From: Andrew Dunstan
Date:
Subject: Re: -f option for pg_dumpall