Skip site navigation (1) Skip section navigation (2)

pgsql: Fix two ancient bugs in GiST code to re-find a parent afterpage

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix two ancient bugs in GiST code to re-find a parent afterpage
Date: 2011-07-15 08:11:58
Message-ID: E1QhdV8-0001XX-Bw@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Fix two ancient bugs in GiST code to re-find a parent after page split:

First, when following a right-link, we incorrectly marked the current page
as the parent of the right sibling. In reality, the parent of the right page
is the same as the parent of the current page (or some page to the right of
it, gistFindCorrectParent() will sort that out).

Secondly, when we follow a right-link, we must prepend, not append, the right
page to our list of pages to visit. That's because we assume that once we
hit a leaf page in the list, all the rest are leaf pages too, and give up.

To hit these bugs, you need concurrent actions and several unlucky accidents.
Another backend must split the root page, while you're in process of
splitting a lower-level page. Furthermore, while you scan the internal nodes
to re-find the parent, another backend needs to again split some more internal
pages. Even then, the bugs don't necessarily manifest as user-visible errors
or index corruption.

While we're at it, make the error reporting a bit better if gistFindPath()
fails to re-find the parent. It used to be an assertion, but an elog() seems
more appropriate.

Backpatch to all supported branches.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/bc175eb8051510a3edd2a561fcfac476e511177c

Modified Files
--------------
src/backend/access/gist/gist.c |   33 ++++++++++++++++++++++++---------
1 files changed, 24 insertions(+), 9 deletions(-)

pgsql-committers by date

Next:From: Heikki LinnakangasDate: 2011-07-15 09:25:31
Subject: pgsql: Change the way the offset of downlink is stored inGISTInsertSta
Previous:From: Bruce MomjianDate: 2011-07-14 21:59:50
Subject: pgsql: In docs,start window function sentence with "The asterisk (*)"

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group