Re: Why does VACUUM FULL bother locking pages?

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Why does VACUUM FULL bother locking pages?
Date: 2005-09-22 15:27:54
Message-ID: 20050922152754.GC30522@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 22, 2005 at 10:36:41AM -0400, Alvaro Herrera wrote:
> On Fri, Sep 16, 2005 at 11:50:21PM -0700, Simon Riggs wrote:
> > > Alvaro Herrera wrote
> > > The only caller of both is
> > > repair_frag, whose only caller in turn is full_vacuum_rel.
> >
> > ...bgwriter still needs to access blocks. The WAL system relies on the
> > locking behaviour for recoverability, see comments in LockBuffer() and
> > SyncOneBuffer().
>
> Oh, certainly! In this case, may I point out that scan_heap() does not
> bother locking pages, mentioning that "we assume that holding exclusive
> lock on the relation will keep other backends from looking at the page".
> In particular, it calls PageRepairFragmentation which runs with the page
> unlocked AFAICT.

Looking again, PageRepairFragmentation is called on a copy of the page,
not on the page itself, so this is not a problem. The page is only
modified to exchange old Xids for FrozenTransactionId, or to set some
hint bits, so this really shouldn't be too much of a problem. I still
think it would be better to lock the page beforehand.

--
Alvaro Herrera Architect, http://www.EnterpriseDB.com
"Uno puede defenderse de los ataques; contra los elogios se esta indefenso"

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-09-22 15:33:50 Re: logging blemishes
Previous Message Jonah H. Harris 2005-09-22 15:19:13 Hierarchical Queries--Stalled No Longer...