Set all_visible_according_to_vm correctly with DISABLE_PAGE_SKIPPING
authorHeikki Linnakangas <[email protected]>
Mon, 11 Mar 2024 07:28:09 +0000 (09:28 +0200)
committerHeikki Linnakangas <[email protected]>
Mon, 11 Mar 2024 07:28:09 +0000 (09:28 +0200)
commit674e49c73c1c442d05a46388fcc1431fbd59ca44
treede0987fa4e14090f1bce93d36cec07772e9d438a
parentaf0e7deb4a1c369bb8154ac55f085d6a93fe5c35
Set all_visible_according_to_vm correctly with DISABLE_PAGE_SKIPPING

It's important for 'all_visible_according_to_vm' to correctly reflect
whether the VM bit is set or not, even when we are not trusting the VM
to skip pages, because contrary to what the comment said,
lazy_scan_prune() relies on it.

If it's incorrectly set to 'false', when the VM bit is in fact set,
lazy_scan_prune() will try to set the VM bit again and dirty the page
unnecessarily. As a result, if you used DISABLE_PAGE_SKIPPING, all
heap pages were dirtied, even if there were no changes. We would also
fail to clear any VM bits that were set incorrectly.

This was broken in commit 980ae17310, so backpatch to v16.

Backpatch-through: 16
Reviewed-by: Melanie Plageman, Peter Geoghegan
Discussion: https://www.postgresql.org/message-id/3df2b582-dc1c-46b6-99b6-38eddd1b2784@iki.fi
src/backend/access/heap/vacuumlazy.c