Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb450abd

Browse files
committed
Remove entry tree root conflict checking from GIN predicate locking
According to README we acquire predicate locks on entry tree leafs and postingtree roots. However, when ginFindLeafPage() is going to lock leaf in exclusivemode, then it checks root for conflicts regardless whether it's a entry orposting tree. Assuming that we never place predicate lock on entry tree root(excluding corner case when root is leaf), this check is redundant. Thiscommit removes this check. Now, root conflict checking is controlled byseparate argument of ginFindLeafPage().Discussion:https://postgr.es/m/CAPpHfdv7rrDyy%3DMgsaK-L9kk0AH7az0B-mdC3w3p0FSb9uoyEg%40mail.gmail.comAuthor: Alexander KorotkovBackpatch-through: 11
1 parent1e504f0 commitb450abd

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

‎src/backend/access/gin/ginbtree.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ ginTraverseLock(Buffer buffer, bool searchMode)
7272
* If 'searchmode' is false, on return stack->buffer is exclusively locked,
7373
* and the stack represents the full path to the root. Otherwise stack->buffer
7474
* is share-locked, and stack->parent is NULL.
75+
*
76+
* If 'rootConflictCheck' is true, tree root is checked for serialization
77+
* conflict.
7578
*/
7679
GinBtreeStack*
77-
ginFindLeafPage(GinBtreebtree,boolsearchMode,Snapshotsnapshot)
80+
ginFindLeafPage(GinBtreebtree,boolsearchMode,
81+
boolrootConflictCheck,Snapshotsnapshot)
7882
{
7983
GinBtreeStack*stack;
8084

@@ -84,7 +88,7 @@ ginFindLeafPage(GinBtree btree, bool searchMode, Snapshot snapshot)
8488
stack->parent=NULL;
8589
stack->predictNumber=1;
8690

87-
if (!searchMode)
91+
if (rootConflictCheck)
8892
CheckForSerializableConflictIn(btree->index,NULL,stack->buffer);
8993

9094
for (;;)

‎src/backend/access/gin/gindatapage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ ginInsertItemPointers(Relation index, BlockNumber rootBlkno,
19131913
{
19141914
/* search for the leaf page where the first item should go to */
19151915
btree.itemptr=insertdata.items[insertdata.curitem];
1916-
stack=ginFindLeafPage(&btree, false,NULL);
1916+
stack=ginFindLeafPage(&btree, false,true,NULL);
19171917

19181918
ginInsertValue(&btree,stack,&insertdata,buildStats);
19191919
}
@@ -1932,7 +1932,7 @@ ginScanBeginPostingTree(GinBtree btree, Relation index, BlockNumber rootBlkno,
19321932

19331933
btree->fullScan= true;
19341934

1935-
stack=ginFindLeafPage(btree, true,snapshot);
1935+
stack=ginFindLeafPage(btree, true,false,snapshot);
19361936

19371937
returnstack;
19381938
}

‎src/backend/access/gin/ginget.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ startScanEntry(GinState *ginstate, GinScanEntry entry, Snapshot snapshot)
338338
ginPrepareEntryScan(&btreeEntry,entry->attnum,
339339
entry->queryKey,entry->queryCategory,
340340
ginstate);
341-
stackEntry=ginFindLeafPage(&btreeEntry, true,snapshot);
341+
stackEntry=ginFindLeafPage(&btreeEntry, true,false,snapshot);
342342
page=BufferGetPage(stackEntry->buffer);
343343

344344
/* ginFindLeafPage() will have already checked snapshot age. */
@@ -679,7 +679,7 @@ entryLoadMoreItems(GinState *ginstate, GinScanEntry entry,
679679
OffsetNumberNext(GinItemPointerGetOffsetNumber(&advancePast)));
680680
}
681681
entry->btree.fullScan= false;
682-
stack=ginFindLeafPage(&entry->btree, true,snapshot);
682+
stack=ginFindLeafPage(&entry->btree, true,false,snapshot);
683683

684684
/* we don't need the stack, just the buffer. */
685685
entry->buffer=stack->buffer;

‎src/backend/access/gin/gininsert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ ginEntryInsert(GinState *ginstate,
195195

196196
ginPrepareEntryScan(&btree,attnum,key,category,ginstate);
197197

198-
stack=ginFindLeafPage(&btree, false,NULL);
198+
stack=ginFindLeafPage(&btree, false,false,NULL);
199199
page=BufferGetPage(stack->buffer);
200200

201201
if (btree.findItem(&btree,stack))

‎src/include/access/gin_private.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ typedef struct
195195
* PostingItem
196196
*/
197197

198-
externGinBtreeStack*ginFindLeafPage(GinBtreebtree,boolsearchMode,Snapshotsnapshot);
198+
externGinBtreeStack*ginFindLeafPage(GinBtreebtree,boolsearchMode,
199+
boolrootConflictCheck,Snapshotsnapshot);
199200
externBufferginStepRight(Bufferbuffer,Relationindex,intlockmode);
200201
externvoidfreeGinBtreeStack(GinBtreeStack*stack);
201202
externvoidginInsertValue(GinBtreebtree,GinBtreeStack*stack,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp