pgsql: amcheck: Fix posting tree checks in gin_index_check()

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: amcheck: Fix posting tree checks in gin_index_check()
Date: 2025-06-17 14:52:24
Message-ID: E1uRXfk-0025Y5-0G@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

amcheck: Fix posting tree checks in gin_index_check()

Fix two issues in parent_key validation in posting trees:

* It's not enough to check stack->parentblk is valid to determine if the
parentkey is valid. It's possible parentblk is set to a valid block
number, but parentkey is invalid. So check parentkey directly.

* We don't need to invalidate parentkey for all child pages of the
rightmost page. It's enough to invalidate it for the rightmost child
only, which means we can check more cases (less false negatives).

Issues reported by Arseniy Mukhin, along with a proposed patch. Review
by Andrey M. Borodin, cleanup and improvements by me.

Author: Arseniy Mukhin <arseniy(dot)mukhin(dot)dev(at)gmail(dot)com>
Reviewed-by: Andrey M. Borodin <x4mmm(at)yandex-team(dot)ru>
Discussion: https://postgr.es/m/CAE7r3MJ611B9TE=YqBBncewp7-k64VWs+sjk7XF6fJUX77uFBA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0cf205e122ae0fe9333ccf843c2269f13ddc32fc

Modified Files
--------------
contrib/amcheck/t/006_verify_gin.pl | 39 +++++++++++++++++++++++++++++++++++++
contrib/amcheck/verify_gin.c | 12 ++++--------
2 files changed, 43 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-06-17 20:49:40 pgsql: Fix allocation check to test the right variable
Previous Message Tomas Vondra 2025-06-17 13:48:24 pgsql: amcheck: Fix parent key check in gin_index_check()