From 3527a5f59fc3821ae985bfb625263a26b00d514c Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Fri, 8 Nov 2013 22:21:42 +0200 Subject: 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/include/access/gin_private.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/include/access/gin_private.h') diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h index a79c003a9f1..ce7069e0d16 100644 --- a/src/include/access/gin_private.h +++ b/src/include/access/gin_private.h @@ -508,6 +508,7 @@ typedef struct GinBtreeData extern GinBtreeStack *ginPrepareFindLeafPage(GinBtree btree, BlockNumber blkno); extern GinBtreeStack *ginFindLeafPage(GinBtree btree, GinBtreeStack *stack); +extern Buffer ginStepRight(Buffer buffer, Relation index, int lockmode); extern void freeGinBtreeStack(GinBtreeStack *stack); extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats); -- cgit v1.2.3