pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Korotkov <akorotkov@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: amcheck: Don't load the right sibling page into BtreeCheckState
Date: Wed, 22 May 2024 23:19:55 +0000
Message-ID: <E1s9vFT-001O9N-Pm@gemulon.postgresql.org> (raw)

amcheck: Don't load the right sibling page into BtreeCheckState

5ae2087202 implemented a cross-page unique constraint check by loading
the right sibling to the BtreeCheckState.target variable.  This is wrong,
because bt_target_page_check() shouldn't change the target page.  Also,
BtreeCheckState.target shouldn't be changed alone without
BtreeCheckState.targetblock.

However, the above didn't cause any visible bugs for the following reasons.
1. We do a cross-page unique constraint check only for leaf index pages.
2. The only way target page get accessed after a cross-page unique constraint
   check is loading of the lowkey.
3. The only place lowkey is used is bt_child_highkey_check(), and that applies
   only to non-leafs.

The reasons above don't diminish the fact that changing BtreeCheckState.target
for a cross-page unique constraint check is wrong.  This commit changes this
check to temporarily store the right sibling to the local variable.

Reported-by: Peter Geoghegan
Discussion: https://postgr.es/m/CAH2-Wzk%2B2116uOXdOViA27SHcr31WKPgmjsxXLBs_aTxAeThzg%40mail.gmail.com
Author: Pavel Borisov

Branch
------
master

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

Modified Files
--------------
contrib/amcheck/verify_nbtree.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)



Message-ID: <E1s9vFT-001O9N-Pm@gemulon.postgresql.org>
Permalink:  ../E1s9vFT-001O9N-Pm@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1s9vFT-001O9N-Pm@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: akorotkov@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: amcheck: Don't load the right sibling page into BtreeCheckState
  In-Reply-To: <E1s9vFT-001O9N-Pm@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox