Re: Bug in amcheck?
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Mihail Nikalayeu <mihailnikalayeu@gmail.com>,
Konstantin Knizhnik <knizhnik@garret.ru>, akorotkov@postgresql.org, aekorotkov@gmail.com, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-25T20:51:06Z
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 →
-
Fix amcheck's handling of half-dead B-tree pages
- fbb4b607832d 14.21 landed
- 7792bdc45860 15.16 landed
- 1829016268c3 16.12 landed
- e8ae594458a3 17.8 landed
- 19e786727c4f 18.2 landed
- cbe04e5d729f 19 (unreleased) landed
-
Fix amcheck's handling of incomplete root splits in B-tree
- a4cb21ea9cd7 14.21 landed
- 721b58fbec5f 15.16 landed
- f2a6df9fd56d 16.12 landed
- 5a2d1df00718 17.8 landed
- 50c63ebb05fc 18.2 landed
- 6c05ef5729c0 19 (unreleased) landed
-
Add a test for half-dead pages in B-tree indexes
- c085aab27819 19 (unreleased) landed
-
Add a test for incomplete splits in B-tree indexes
- 1e4e5783e7d7 19 (unreleased) landed
-
Improve checking of child pages in contrib/amcheck.
- d114cc538715 13.0 cited
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