Re: Bug in amcheck?

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com>, Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, akorotkov(at)postgresql(dot)org, aekorotkov(at)gmail(dot)com, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Bug in amcheck?
Date: 2025-11-25 20:51:06
Message-ID: CAH2-Wzkne0wy49wxHaL5e3mfOZztrVFOP=+VdtqqFBYg0hsAkw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 25, 2025 at 3:03 PM Heikki Linnakangas <hlinnaka(at)iki(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2025-11-25 20:58:47 Re: pgsql: Teach DSM registry to ERROR if attaching to an uninitialized ent
Previous Message Andres Freund 2025-11-25 20:46:49 Re: Buffer locking is special (hints, checksums, AIO writes)