]> granicus.if.org Git - postgresql/commit
Fix race condition in GIN posting tree page deletion.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 8 Nov 2013 20:21:42 +0000 (22:21 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 8 Nov 2013 20:23:11 +0000 (22:23 +0200)
commit9a45a655977266c5367d658bab8384d8d4c77127
treebd6413c2fbadaa8ed7302dd1e376f8706d936b5c
parentf7171c7e26d7e2a7117dbc3d3a9fa863a2decf59
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.
src/backend/access/gin/README
src/backend/access/gin/ginbtree.c
src/backend/access/gin/ginget.c
src/backend/access/gin/ginvacuum.c
src/include/access/gin_private.h