]> 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:14 +0000 (22:23 +0200)
commit3527a5f59fc3821ae985bfb625263a26b00d514c
tree6ffa7a2a4f479b9e0cbed8c0eee2534a90ac253c
parentaf38d140c71c21eda422fedc838525525d155cac
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