Re: Corrupted btree index on HEAD because of covering indexes
Teodor Sigaev <teodor@sigaev.ru>
From: Teodor Sigaev <teodor@sigaev.ru>
To: Peter Geoghegan <pg@bowt.ie>
Cc: Michael Paquier <michael@paquier.xyz>,
Postgres hackers <pgsql-hackers@postgresql.org>,
Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
Date: 2018-04-19T16:42:59Z
Lists: pgsql-hackers
Attachments
- vacuum_nbtree.patch (text/x-patch) patch
> I'll take a look tomorrow.
Interesting, contrib/amcheck doesn't find any error in index. Seems, it's
subject for further improvement.
Nevertheless, seems, I found. In _bt_mark_page_halfdead() we use truncated high
key IndexTuple as a storage of blocknumber of top parent to remove. And sets
BTreeTupleSetNAtts(&trunctuple, 0) - it's stored in ip_posid.
But some later, in _bt_unlink_halfdead_page() we check ItemPointer high key with
ItemPointerIsValid macro - and it returns false, because offset is actually
InvalidOffsetNumber - i.e. 0 which was set by BTreeTupleSetNAtts. And some wrong
decisions are follows, I didn't look at that.
Trivial and naive fix is attached, but for me it looks a bit annoing that we
store pointer (leafhikey) somewhere inside unlocked page.
--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/
Commits
-
Add missing and dangling downlink checks to amcheck
- 4eaf7eaccb29 11.0 landed
-
Fix wrong validation of top-parent pointer during page deletion in Btree.
- 6db4b49986be 11.0 landed
-
Add integrity-checking functions to pg_visibility.
- e472ce9624e0 9.6.0 cited
-
Make the handling of interrupted B-tree page splits more robust.
- 40dae7ec537c 9.4.0 cited