Re: Bug in amcheck? - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Bug in amcheck?
Date
Msg-id CAH2-Wzkne0wy49wxHaL5e3mfOZztrVFOP=+VdtqqFBYg0hsAkw@mail.gmail.com
Whole thread Raw
In response to Re: Bug in amcheck?  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers
On Tue, Nov 25, 2025 at 3:03 PM Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> To fix this, I guess we need to teach bt_index_parent_check() about
> half-dead pages. Anyone volunteer to write that patch?

It's not like bt_index_parent_check doesn't generally know about them.
For example, bt_downlink_missing_check goes to great lengths to
distinguish between legitimate "missing" downlinks caused by an
interrupted page deletion, and real missing downlinks caused by
corruption.

The problem we're seeing here seems likely limited to code added by
commit d114cc53, which enhanced bt_index_parent_check by adding the
new bt_child_highkey_check check. bt_child_highkey_check actually
reuses bt_downlink_missing_check (which deals with half-dead pages
correctly), but still isn't careful enough about half-dead pages. This
is kind of surprising, since it *does* account for incomplete splits,
which are similar.

In short, I think that we need to track something like
BtreeCheckState.previncompletesplit, but for half-dead pages. And then
actually use that within bt_child_highkey_check, to avoid spurious
false-positive reports of corruption.

--
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Buffer locking is special (hints, checksums, AIO writes)
Next
From: Robert Haas
Date:
Subject: Re: pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent