amcheck: Fix posting tree checks in gin_index_check() master github/master
authorTomas Vondra <[email protected]>
Tue, 17 Jun 2025 14:48:09 +0000 (16:48 +0200)
committerTomas Vondra <[email protected]>
Tue, 17 Jun 2025 14:48:11 +0000 (16:48 +0200)
commit0cf205e122ae0fe9333ccf843c2269f13ddc32fc
treedb9c65227ae40de269eabc0b390949cf2c4c4980
parentcdd1a431f21dbd2b7b675a9db1c24b97d713f38b
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 <[email protected]>
Reviewed-by: Andrey M. Borodin <[email protected]>
Discussion: https://postgr.es/m/CAE7r3MJ611B9TE=YqBBncewp7-k64VWs+sjk7XF6fJUX77uFBA@mail.gmail.com
contrib/amcheck/t/006_verify_gin.pl
contrib/amcheck/verify_gin.c