Re: Why does VACUUM FULL bother locking pages? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Why does VACUUM FULL bother locking pages?
Date
Msg-id 4897.1126933164@sss.pgh.pa.us
Whole thread Raw
In response to Why does VACUUM FULL bother locking pages?  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers
Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> So, the only callers of both has already acquired appropiate locks at
> the relation level -- nobody is going to be modifying the blocks while
> they proceed.  So why bother locking the pages at all?  Is there a
> reason or is this an historical accident?

No, because operations such as checkpointing and bgwriter will feel free
to write out pages that aren't exclusive-locked; they don't try to get
a lock at the table level.  Failing to lock the buffer would risk
allowing an invalid page state to be written to disk --- which, if we
then crashed before writing the WAL record for the vacuum operation,
would represent unrecoverable corruption.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Gavin Sherry
Date:
Subject: Re: Spinlocks, yet again: analysis and proposed patches
Next
From: Tom Lane
Date:
Subject: Re: Spinlocks, yet again: analysis and proposed patches