Re: Corrupted btree index on HEAD because of covering indexes

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Postgres hackers <pgsql-hackers(at)postgresql(dot)org>, Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>
Subject: Re: Corrupted btree index on HEAD because of covering indexes
Date: 2018-04-19 16:42:59
Message-ID: 97545a73-3a3b-713d-31e2-8e652faa9152@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 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(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

Attachment Content-Type Size
vacuum_nbtree.patch text/x-patch 618 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-04-19 17:20:54 Re: ON CONFLICT DO UPDATE for partitioned tables
Previous Message Alvaro Herrera 2018-04-19 15:05:31 Re: pruning disabled for array, enum, record, range type partition keys