Thread: autovacuum bootstrap

autovacuum bootstrap

From
Alvaro Herrera
Date:
Hackers,

There's one problem with autovacuum and it's how to bootstrap it.

My current approach is to connect to a default hardcoded database :-)  
so it has to be changed to be useful.

I added two new fields to the pg_database flatfile and table, datstats
and datautovac.  They respectively signal the stat collector and
autovacuum daemon to run for that database.

Additionally I need to save some state during initdb for each database,
and during database creation (and when the hypotetical ALTER DATABASE
command for turning autovacuum on is executed).  I'm thinking in storing
that state in additional flat files.  The reason is that we need to
examine the state of all databases before deciding which one to connect
to.  I don't want to use the pg_database file, because that'd make me
check for race conditions against created or dropped databases; the new
flatfile would only need to interlock against autovac processes (which
is trivial because only one autovac process runs at any time.)

Does anyone see a problem with this approach?


PS -- it would definitely be much easier if there was one autovac
process per database :-(

-- 
Alvaro Herrera (<alvherre[a]surnet.cl>)
"El realista sabe lo que quiere; el idealista quiere lo que sabe" (Anónimo)


Re: autovacuum bootstrap

From
Tom Lane
Date:
Alvaro Herrera <alvherre@surnet.cl> writes:
> I added two new fields to the pg_database flatfile and table, datstats
> and datautovac.  They respectively signal the stat collector and
> autovacuum daemon to run for that database.

Why?  I can't see a particularly good reason to be able to suppress
these daemons per-database.

> Additionally I need to save some state during initdb for each database,
> and during database creation (and when the hypotetical ALTER DATABASE
> command for turning autovacuum on is executed).

Shouldn't this live in the existing stats collector output file?
Exactly what state have you got in mind?
        regards, tom lane


Re: autovacuum bootstrap

From
Alvaro Herrera
Date:
On Sat, Jun 25, 2005 at 03:52:08PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre@surnet.cl> writes:
> > I added two new fields to the pg_database flatfile and table, datstats
> > and datautovac.  They respectively signal the stat collector and
> > autovacuum daemon to run for that database.
> 
> Why?  I can't see a particularly good reason to be able to suppress
> these daemons per-database.

Just to be nice, I guess.  I assume we will be asked to turn at least
autovacuum off on some databases; and there's a comment on top of the
pgstat.c file stating that it needs to be controlled on a per-database
entry.

I'll leave that part of the patch separate, anyway.


> > Additionally I need to save some state during initdb for each database,
> > and during database creation (and when the hypotetical ALTER DATABASE
> > command for turning autovacuum on is executed).
> 
> Shouldn't this live in the existing stats collector output file?

Ah, interesting.  I'll have a look at that.

-- 
Alvaro Herrera (<alvherre[a]surnet.cl>)
"The important things in the world are problems with society that we don't
understand at all. The machines will become more complicated but they won't
be more complicated than the societies that run them."    (Freeman Dyson)