Re: WAL_LOG CREATE DATABASE strategy broken for non-standard page layouts

From: surya poondla <suryapoondla4(at)gmail(dot)com>
To: "houzhijie22(at)gmail(dot)com" <houzhijie22(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Rogers Wang <rogers(dot)ww(at)qq(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Andres Freund <andres(at)anarazel(dot)de>, Melanie Plageman <melanieplageman(at)gmail(dot)com>
Subject: Re: WAL_LOG CREATE DATABASE strategy broken for non-standard page layouts
Date: 2026-11-17 23:19:26
Message-ID: CAOVWO5qBu7Rsm-NS+9trRWcr-Lkz1HnOr0GTE3A4OCuSD1j7PQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Zhijie,

Nice find on the verifyBackupPageConsistency(). I tried your draft patch
with a primary and a streaming
standby, both with wal_consistency_checking = 'heap,heap2'.

With your patch on master, the standby stops after a plain CREATE DATABASE
from template1, on a catalog insert (from CREATE EXTENSION) in the new
database:

FATAL: inconsistent page found, rel 1663/16384/2608, forknum 2, blkno 0

With v3 applied as well, the same workload runs clean.

The fix looks good to me. One small comment, special-casing
VISIBILITYMAP_FORKNUM in verifyBackupPageConsistency() makes sense to
avoid changing rm_mask(). On master it might be cleaner to pass the fork
number to rm_mask and let heap_mask() skip mask_unused_space() for VM
pages, keeping your approach for the back branches.

Separately, since VM pages are now actually compared, any VM change that
bypasses WAL will show up as an inconsistency.
heap_page_fix_vm_corruption() in pruneheap.c clears corrupted VM bits
without WAL ("This VM clear is not WAL-logged ..."), would it make sense to
WAL-log that clear?
Today the repair only fixes the primary, a standby keeps the corrupted bit,
so its index-only scans can still trust it, and it comes back after a
failover.
WAL-Logging it would fix the standby too and keep the new check from
tripping over it. That's probably a separate patch, though.

Regards,
Surya Poondla

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonah Shafran 2026-11-17 23:39:23 Re: ISBN range table
Previous Message Peter Smith 2026-11-17 23:15:50 Re: Initial table sync copies the whole table when it is no longer published