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

Commit6cefacd

Browse files
committed
Correct an old logic error in btree page splitting: when considering a split
exactly at the point where we need to insert a new item, the calculation usedthe wrong size for the "high key" of the new left page. This could lead tochoosing an unworkable split, resulting in "PANIC: failed to add item to theleft sibling" (or "right sibling") failure. Although this bug has been therea long time, it's very difficult to trigger a failure before 8.2, since therewas generally a lot of free space on both sides of a chosen split. In 8.2,where the user-selected fill factor determines how much free space the codetries to leave, an unworkable split is much more likely. Report by JoeConway, diagnosis and fix by Heikki Linnakangas.
1 parent0fe1c36 commit6cefacd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎src/backend/access/nbtree/nbtinsert.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.147 2007/01/05 22:19:23 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.148 2007/01/27 20:53:30 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1153,7 +1153,12 @@ _bt_findsplitloc(Relation rel,
11531153
/* need to try it both ways! */
11541154
_bt_checksplitloc(&state,offnum,leftfree,rightfree,
11551155
true,itemsz);
1156-
/* here we are contemplating newitem as first on right */
1156+
/*
1157+
* Here we are contemplating newitem as first on right. In this
1158+
* case it, not the current item, will become the high key of the
1159+
* left page, and so we have to correct the allowance made above.
1160+
*/
1161+
leftfree+= (int)itemsz- (int)newitemsz;
11571162
_bt_checksplitloc(&state,offnum,leftfree,rightfree,
11581163
false,newitemsz);
11591164
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp