Re: _bt_delitems: change before WAL?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: _bt_delitems: change before WAL?
Date: 2008-07-11 19:31:33
Message-ID: 19137.1215804693@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> It's often said that the golden rule of WAL is that we must log the
> changes before actually doing the changes.

No, the golden rule is that the log entry must hit disk before the
data-page changes do. This does not speak to the order in which you
make the changes in memory.

> However it seems to me that
> in _bt_delitems we're modifying the page (calling PageIndexMultiDelete)
> before actually logging what's going to happen. Why is this OK?

Because we have write lock on the buffer, which will prevent anyone else
from writing it out (or even looking at it). This is exactly like all the
other WAL-logging actions; see the WAL coding rules in access/transam/README.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zdenek Kotala 2008-07-11 19:37:31 Re: PATCH: CITEXT 2.0 v3
Previous Message Tom Lane 2008-07-11 19:17:08 Re: 8.1 index corruption woes