pgsql: Set the all-visible flag on heap page before writing WAL record,

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Set the all-visible flag on heap page before writing WAL record,
Date: 2014-04-17 14:48:28
Message-ID: E1Wanc4-0004Yi-Ez@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Set the all-visible flag on heap page before writing WAL record, not after.

If we set the all-visible flag after writing WAL record, and XLogInsert
takes a full-page image of the page, the image would not include the flag.
We will then proceed to set the VM bit, which would then be set without the
corresponding all-visible flag on the heap page.

Found by comparing page images on master and standby, after writing/replaying
each WAL record. (There is still a discrepancy: the all-visible flag won't
be set after replaying the HEAP_CLEAN record, even though it is set in the
master. However, it will be set when replaying the HEAP2_VISIBLE record and
setting the VM bit, so the all-visible flag and VM bit are always consistent
on the standby, even though they are momentarily out-of-sync with master)

Backpatch to 9.3 where this code was introduced.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/95aa823eb611a1280c1ab80c651c1ae62719b3e2

Modified Files
--------------
src/backend/commands/vacuumlazy.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2014-04-17 14:53:15 pgsql: docs: adjustments for streaming standbys that disconnect frequen
Previous Message Andreas Karlsson 2014-04-17 09:53:08 Re: [COMMITTERS] pgsql: Include planning time in EXPLAIN ANALYZE output.