Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Autovacuum improvements

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] Autovacuum improvements
Date: 2007-01-15 20:31:29
Message-ID: 20070115203129.GS7233@alvh.no-ip.org (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Tom Lane wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > Note that currently there's no way for a backend to know whether another
> > backend is autovacuum or not.  I thought about adding a flag to PGPROC,
> > but eventually considered it ugly,
> 
> No, that was exactly the way I thought we'd do it.  One thing to note is
> that to avoid race conditions, the PGPROC entry has to be marked as
> autovac from the instant it's inserted into the array --- with a
> separate area I think you'd have difficulty avoiding the race condition.

Here it is.

I have run the regression tests many times and they pass.  I added some
debug printouts (not in the patch) to make sure the kill code path was
being invoked, and while it seldom shows, it certainly does.

Note that I used the same DatabaseHasActiveBackends() function to do the
kill.  I had first added a different one to kill autovacuum, but then
noticed that this one has no callers that don't want the side effect, so
I merged them.  It seems a bit ugly to me to have a function named like
this and still have the side effect, but on the other hand it's quite
useless to have a version without the side effect that will never get
called.

Another point to make is that it only kills autovacuum, and only if no
other process is found.  So if there are two processes and autovacuum is
one of them, it will be allowed to continue.

I feel that changing the DROP DATABASE behavior with respect to killing
other backends is beyond the scope of this patch.  It seems easy enough
to do if somebody feels so inclined.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

Attachment: kill-autovacuum.patch
Description: text/x-diff (10.0 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Neil ConwayDate: 2007-01-15 20:35:32
Subject: Re: Function execution costs 'n all that
Previous:From: Tom LaneDate: 2007-01-15 20:05:06
Subject: Re: Function execution costs 'n all that

pgsql-patches by date

Next:From: Tom LaneDate: 2007-01-15 20:40:51
Subject: Re: [HACKERS] Autovacuum improvements
Previous:From: Tom LaneDate: 2007-01-15 19:49:46
Subject: Re: scrollable cursor sup. for SPI

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group