Re: Bug in amcheck?

Mikhail Nikalayeu <mihailnikalayeu@gmail.com>

From: Mihail Nikalayeu <mihailnikalayeu@gmail.com>
To: Konstantin Knizhnik <knizhnik@garret.ru>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-02T12:27:00Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix amcheck's handling of half-dead B-tree pages

  2. Fix amcheck's handling of incomplete root splits in B-tree

  3. Add a test for half-dead pages in B-tree indexes

  4. Add a test for incomplete splits in B-tree indexes

  5. Improve checking of child pages in contrib/amcheck.

Hello!

> I wonder if we should add P_ISHALFDEAD(opaque) for child page?

I am not a btree expert, but things I was able to find so far:

In commit d114cc538715e14d29d6de8b6ea1a1d5d3e0edb4 next check is added:

> bt_child_highkey_check(state, downlinkoffnum,
>                   child, topaque->btpo_level);

At the same time there is a comment below:

> * We go ahead with our checks if the child page is half-dead.  It's safe
> * to do so because we do not test the child's high key, so it does not
> * matter that the original high key will have been replaced by a dummy
> * truncated high key within _bt_mark_page_halfdead().  All other page
> * items are left intact on a half-dead page, so there is still something
> * to test.

So, yes, it looks like we need to skip the child's high key test for
half-dead pages.

BWT, have you tried to create an injection_point-based reproducer?

Best regards,
Mikhail.