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

Commit7392eed

Browse files
committed
Fix btree mark/restore bug.
Commit2ed5b87 introduced a bug inmark/restore, in an attempt to optimize repeated restores to thesame page. This caused an assertion failure during a merge joinwhich fed directly from an index scan, although the impact wouldnot be limited to that case. Revert the bad chunk of code fromthat commit.While investigating this bug it was discovered that a particular"paranoia" set of the mark position field would not prevent badbehavior; it would just make it harder to diagnose. Change thatinto an assertion, which will draw attention to any future problemin that area more directly.Backpatch to 9.5, where the bug was introduced.Bug #14169 reported by Shinta Koyanagi.Preliminary analysis by Tom Lane identified which commit causedthe bug.
1 parent763eec6 commit7392eed

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -608,25 +608,6 @@ btrestrpos(IndexScanDesc scan)
608608
*/
609609
so->currPos.itemIndex=so->markItemIndex;
610610
}
611-
elseif (so->currPos.currPage==so->markPos.currPage)
612-
{
613-
/*
614-
* so->markItemIndex < 0 but mark and current positions are on the
615-
* same page. This would be an unusual case, where the scan moved to
616-
* a new index page after the mark, restored, and later restored again
617-
* without moving off the marked page. It is not clear that this code
618-
* can currently be reached, but it seems better to make this function
619-
* robust for this case than to Assert() or elog() that it can't
620-
* happen.
621-
*
622-
* We neither want to set so->markItemIndex >= 0 (because that could
623-
* cause a later move to a new page to redo the memcpy() executions)
624-
* nor re-execute the memcpy() functions for a restore within the same
625-
* page. The previous restore to this page already set everything
626-
* except markPos as it should be.
627-
*/
628-
so->currPos.itemIndex=so->markPos.itemIndex;
629-
}
630611
else
631612
{
632613
/*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
10111011
so->currPos.moreRight= false;
10121012
}
10131013
so->numKilled=0;/* just paranoia */
1014-
so->markItemIndex=-1;/* ditto */
1014+
Assert(so->markItemIndex==-1);
10151015

10161016
/* position to the precise item on the page */
10171017
offnum=_bt_binsrch(rel,buf,keysCount,scankeys,nextkey);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp