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-0008LO-EG@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_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/4b099e1bff528a149129732e4d5a1bf020f842ea

Modified Files
--------------
src/backend/access/gin/README      |   50 ++++++++++++++++++++++++++++++++++
src/backend/access/gin/ginbtree.c  |   53 ++++++++++++++++++++++++++++--------
src/backend/access/gin/ginget.c    |   25 ++++-------------
src/backend/access/gin/ginvacuum.c |   51 +++++++++++++++-------------------
src/include/access/gin.h           |    1 +
5 files changed, 121 insertions(+), 59 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.