pgsql: Fix race condition in GIN posting tree page deletion. - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: Fix race condition in GIN posting tree page deletion.
Date
Msg-id E1Vesg9-0008LI-36@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix race condition in GIN posting tree page deletion.

If a page is deleted, and reused for something else, just as a search is
following a rightlink to it from its left sibling, the search would continue
scanning whatever the new contents of the page are. That could lead to
incorrect query results, or even something more curious if the page is
reused for a different kind of a page.

To fix, modify the search algorithm to lock the next page before releasing
the previous one, and refrain from deleting pages from the leftmost branch
of the tree.

Add a new Concurrency section to the README, explaining why this works.
There is a lot more one could say about concurrency in GIN, but that's for
another patch.

Backpatch to all supported versions.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/9a45a655977266c5367d658bab8384d8d4c77127

Modified Files
--------------
src/backend/access/gin/README      |   50 ++++++++++++++++++++++++++++++++++
src/backend/access/gin/ginbtree.c  |   53 ++++++++++++++++++++++++++++--------
src/backend/access/gin/ginget.c    |   31 ++++++---------------
src/backend/access/gin/ginvacuum.c |   51 +++++++++++++++-------------------
src/include/access/gin_private.h   |    1 +
5 files changed, 123 insertions(+), 63 deletions(-)


pgsql-committers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: pgsql: Fix race condition in GIN posting tree page deletion.
Next
From: Heikki Linnakangas
Date:
Subject: pgsql: Fix race condition in GIN posting tree page deletion.