aboutsummaryrefslogtreecommitdiff
path: root/src/include/access/gin_private.h
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-11-08 22:21:42 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2013-11-08 22:23:03 +0200
commitfc545a2548a4a2be1a66c6a4a8c36ee7b4dc264c (patch)
tree5cb193acbc38c400bfe71abc9cdbeab60fe7e27b /src/include/access/gin_private.h
parent9548bee2b19bee71e565a0a0aedd4d38ccb10a91 (diff)
downloadpostgresql-fc545a2548a4a2be1a66c6a4a8c36ee7b4dc264c.tar.gz
postgresql-fc545a2548a4a2be1a66c6a4a8c36ee7b4dc264c.zip
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.
Diffstat (limited to 'src/include/access/gin_private.h')
-rw-r--r--src/include/access/gin_private.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h
index 1868b77df10..8e45ecf760b 100644
--- a/src/include/access/gin_private.h
+++ b/src/include/access/gin_private.h
@@ -513,6 +513,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);