Re: [PATCH] Improve amcheck to also check UNIQUE constraint in btree index.
Noah Misch <noah@leadboat.com>
From: Noah Misch <noah@leadboat.com>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Pavel Borisov <pashkin.elfe@gmail.com>, Alexander Korotkov <aekorotkov@gmail.com>, Aleksander Alekseev <aleksander@timescale.com>, Postgres hackers <pgsql-hackers@lists.postgresql.org>, Maxim Orlov <orlovmg@gmail.com>, Andres Freund <andres@anarazel.de>, Greg Stark <stark@mit.edu>, Julien Rouhaud <rjuju123@gmail.com>, Mark Dilger <mark.dilger@enterprisedb.com>, David Steele <david@pgmasters.net>, Maxim Orlov <m.orlov@postgrespro.ru>, lubennikovaav@gmail.com, Hamid Akhtar <hamid.akhtar@percona.com>
Date: 2024-03-29T23:47:52Z
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 →
-
amcheck: Optimize speed of checking for unique constraint violation
- cdd6ab9d1f53 18.0 landed
-
amcheck: Report an error when the next page to a leaf is not a leaf
- 97e5b0026fc2 17.0 landed
-
amcheck: Don't load the right sibling page into BtreeCheckState
- 0b5c16124811 17.0 landed
-
amcheck: Refactoring the storage of the last visible entry
- 532d94fec32a 17.0 landed
-
Teach contrib/amcheck to check the unique constraint violation
- 5ae2087202af 17.0 landed
-
Add macros in hash and btree AMs to get the special area of their pages
- d16773cdc862 15.0 cited
On Fri, Mar 29, 2024 at 02:17:08PM -0400, Peter Geoghegan wrote: > On Mon, Mar 25, 2024 at 2:24 PM Noah Misch <noah@leadboat.com> wrote: > > I wasn't thinking about changing the pre-v17 bt_right_page_check_scankey() > > code. I got interested in this area when I saw the interaction of the new > > "first key on the next page" logic with bt_right_page_check_scankey(). The > > patch made bt_right_page_check_scankey() pass back rightfirstoffset. The new > > code then does palloc_btree_page() and PageGetItem() with that offset, which > > bt_right_page_check_scankey() had already done. That smelled like a misplaced > > distribution of responsibility. For a time, I suspected the new code should > > move down into bt_right_page_check_scankey(). Then I transitioned to thinking > > checkunique didn't need new code for the page boundary. > I did notice (I meant to point out) that I have concerns about this > part of the new uniqueness check code: > > " > if (P_IGNORE(topaque) || !P_ISLEAF(topaque)) > break; > " > > My concern here is with the !P_ISLEAF(topaque) test -- it shouldn't be > required. If the page in question isn't a leaf page, then the index > must be corrupt (or the page deletion recycle safety/drain technique > thing is buggy). The " !P_ISLEAF(topaque)" part of the check is either > superfluous or something that ought to be reported as corruption -- > it's not a legal/expected state. Good point. > Separately, I dislike the way the target block changes within > bt_target_page_check(). The general idea behind verify_nbtree.c's > target block is that every block becomes the target exactly once, in a > clearly defined place. Agreed.