Re: Stop masking visibility information during WAL consistency checking

From: surya poondla <suryapoondla4(at)gmail(dot)com>
To: Melanie Plageman <melanieplageman(at)gmail(dot)com>
Cc: Zhijie Hou <houzhijie22(at)gmail(dot)com>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Andres Freund <andres(at)anarazel(dot)de>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: Stop masking visibility information during WAL consistency checking
Date: 2026-12-02 20:13:10
Message-ID: CAOVWO5qq+c4ny1PSt0xhA6G42eHWGjH6A66PL0u5pLGd-0QHsg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Melanie,

I tested your skip-uninitialized-pages patch on master (a1b679076f8). On
master without it, both Zhijie's re-extend case and the scenario from your
new 036 test (which I ran by hand, not via TAP) fail recovery with "invalid
page pd_lower 0 pd_upper 0 pd_special 0" whenever full_page_writes = off,
with or without checksums. With the patch they recover fine, also on top of
previous v1 0001+0002.

It isn't only truncation to zero, either. With wal_consistency_checking =
all, a heap truncated to 2 blocks and then re-extended fails the same way
on block 2, and the patch fixes that too. A broader workload under
wal_consistency_checking = all (VACUUM/FREEZE, DML, row locks, COPY FREEZE,
CLUSTER, btree and hash indexes) didn't turn up anything else.

Andrey asked which settings each check depends on. To help with that, I
reran the failing cases (with 0001+0002 and your latest patch) under
different settings:
1. Zsolt's two cases (PD_ALL_VISIBLE, and the VM truncation) fail only when
full_page_writes = off and neither data checksums nor wal_log_hints is on.
Turning on any one of those three makes them pass.
2. The DROP TABLE case fails whenever full_page_writes = off, regardless of
checksums or wal_log_hints.

Your commit message says the original user of RBM_NORMAL_NO_LOG (the btree
code) is gone. I checked, and the only remaining caller is
verifyBackupPageConsistency(), so changing how that mode handles all-zero
pages only affects WAL consistency checking.

One question. The patch now skips any all-zero page. Under consistency
checking, WILL_INIT blocks carry an image that gets compared, so a redo
routine that failed to initialize one is caught today. With the patch, it
would just be skipped. Would it make sense to keep comparing WILL_INIT
blocks, as Zhijie suggested? I don't have a case where this hides a real
bug, so it's just a question.

A couple of small nits
1. "consitency" typo in the commit message,
2. The new test could also cover a partial truncation, since it goes
through the same path.

Thanks,
Surya Poondla

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Burd 2026-12-02 20:44:13 Re: Quickselect instead of a heap for ORDER BY ... LIMIT N large bounded sorts
Previous Message Masahiko Sawada 2026-12-02 18:49:59 Re: Fix LogStandbySnapshot() race during logical decoding activation