Set the all-visible flag on heap page before writing WAL record, not after.
authorHeikki Linnakangas <[email protected]>
Thu, 17 Apr 2014 14:47:50 +0000 (17:47 +0300)
committerHeikki Linnakangas <[email protected]>
Thu, 17 Apr 2014 14:47:58 +0000 (17:47 +0300)
commit95aa823eb611a1280c1ab80c651c1ae62719b3e2
tree94ddc801b3405756ab10b3754e7c03810371907e
parentaa0a5198baba5bbf04081393e77d07ac3febc153
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.
src/backend/commands/vacuumlazy.c