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

Commit741b884

Browse files
committed
Fix yet another crash in page split during GiST index creation.
Commita7ee7c8 fixed a bug in GiST page split during index creation,where we failed to re-find the position of a downlink after the pagecontaining it was split. However, that fix was incomplete; the other callto gistinserttuples() in the same function needs to also clear'downlinkoffnum'.Fixes bug #16134 reported by Alexander Lakhin, for real this time. Theprevious fix was enough to fix the crash with the reproducer script forbug #16162, but the original script for #16134 was still crashing.Backpatch to v12, like the previous incomplete fix.Discussion:https://www.postgresql.org/message-id/d869f537-abe4-d2ea-0510-38cd053f5152%40gmail.com
1 parent5024231 commit741b884

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

‎src/backend/access/gist/gist.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,28 +1325,27 @@ gistfinishsplit(GISTInsertState *state, GISTInsertStack *stack,
13251325
* downlink for the original page as one operation.
13261326
*/
13271327
LockBuffer(stack->parent->buffer,GIST_EXCLUSIVE);
1328-
gistFindCorrectParent(state->r,stack);
13291328

13301329
/*
1331-
*insert downlinks for the siblings from right to left, until there are
1330+
*Insert downlinks for the siblings from right to left, until there are
13321331
* only two siblings left.
13331332
*/
13341333
for (intpos=list_length(splitinfo)-1;pos>1;pos--)
13351334
{
13361335
right= (GISTPageSplitInfo*)list_nth(splitinfo,pos);
13371336
left= (GISTPageSplitInfo*)list_nth(splitinfo,pos-1);
13381337

1338+
gistFindCorrectParent(state->r,stack);
13391339
if (gistinserttuples(state,stack->parent,giststate,
13401340
&right->downlink,1,
13411341
InvalidOffsetNumber,
13421342
left->buf,right->buf, false, false))
13431343
{
13441344
/*
1345-
* If the parent page was split,need to relocate the original
1346-
*parent pointer.
1345+
* If the parent page was split,the existing downlink might
1346+
*have moved.
13471347
*/
13481348
stack->downlinkoffnum=InvalidOffsetNumber;
1349-
gistFindCorrectParent(state->r,stack);
13501349
}
13511350
/* gistinserttuples() released the lock on right->buf. */
13521351
}
@@ -1361,13 +1360,21 @@ gistfinishsplit(GISTInsertState *state, GISTInsertStack *stack,
13611360
*/
13621361
tuples[0]=left->downlink;
13631362
tuples[1]=right->downlink;
1364-
gistinserttuples(state,stack->parent,giststate,
1365-
tuples,2,
1366-
stack->downlinkoffnum,
1367-
left->buf,right->buf,
1368-
true,/* Unlock parent */
1369-
unlockbuf/* Unlock stack->buffer if caller wants that */
1370-
);
1363+
gistFindCorrectParent(state->r,stack);
1364+
if (gistinserttuples(state,stack->parent,giststate,
1365+
tuples,2,
1366+
stack->downlinkoffnum,
1367+
left->buf,right->buf,
1368+
true,/* Unlock parent */
1369+
unlockbuf/* Unlock stack->buffer if caller wants that */
1370+
))
1371+
{
1372+
/*
1373+
* If the parent page was split, the downlink might have moved.
1374+
*/
1375+
stack->downlinkoffnum=InvalidOffsetNumber;
1376+
}
1377+
13711378
Assert(left->buf==stack->buffer);
13721379

13731380
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp