From: Teodor Sigaev <teodor@sigaev.ru>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix wrong validation of top-parent pointer during page deletion
Date: Mon, 23 Apr 2018 12:55:50 +0000
Message-ID: <E1fAb0Y-0001CK-3O@gemulon.postgresql.org> (raw)
Fix wrong validation of top-parent pointer during page deletion in Btree.
After introducing usage of t_tid of inner or page high key for storing
number of attributes of tuple, validation of tuple's ItemPointer with
ItemPointerIsValid becomes incorrect, it's need to validate only blocknumber of
ItemPointer. Missing this causes a incorrect page deletion, fix that. Test is
added.
BTW, current contrib/amcheck doesn't fail on index corrupted by this way.
Also introduce BTreeTupleGetTopParent/BTreeTupleSetTopParent macroses to improve
code readability and to avoid possible confusion with page high key: high key
is used to store top-parent link for branch to remove.
Bug found by Michael Paquier, but bug doesn't exist in previous versions because
t_tid was set to P_HIKEY.
Author: Teodor Sigaev
Reviewer: Peter Geoghegan
Discussion: https://www.postgresql.org/message-id/flat/20180419052436.GA16000%40paquier.xyz
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/6db4b49986be3fe59a1f6ba6fabf9852864efc3e
Modified Files
--------------
src/backend/access/nbtree/nbtpage.c | 21 ++++++++-------------
src/backend/access/nbtree/nbtxlog.c | 12 ++----------
src/include/access/nbtree.h | 14 ++++++++++++++
src/test/regress/expected/create_index.out | 10 ++++++++++
src/test/regress/expected/sanity_check.out | 1 +
src/test/regress/sql/create_index.sql | 11 +++++++++++
6 files changed, 46 insertions(+), 23 deletions(-)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: teodor@sigaev.ru
Subject: Re: pgsql: Fix wrong validation of top-parent pointer during page deletion
In-Reply-To: <E1fAb0Y-0001CK-3O@gemulon.postgresql.org>
References: <E1fAb0Y-0001CK-3O@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