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

Commit236d569

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 parent43d3fbe commit236d569

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
@@ -592,25 +592,6 @@ btrestrpos(PG_FUNCTION_ARGS)
592592
*/
593593
so->currPos.itemIndex=so->markItemIndex;
594594
}
595-
elseif (so->currPos.currPage==so->markPos.currPage)
596-
{
597-
/*
598-
* so->markItemIndex < 0 but mark and current positions are on the
599-
* same page. This would be an unusual case, where the scan moved to
600-
* a new index page after the mark, restored, and later restored again
601-
* without moving off the marked page. It is not clear that this code
602-
* can currently be reached, but it seems better to make this function
603-
* robust for this case than to Assert() or elog() that it can't
604-
* happen.
605-
*
606-
* We neither want to set so->markItemIndex >= 0 (because that could
607-
* cause a later move to a new page to redo the memcpy() executions)
608-
* nor re-execute the memcpy() functions for a restore within the same
609-
* page. The previous restore to this page already set everything
610-
* except markPos as it should be.
611-
*/
612-
so->currPos.itemIndex=so->markPos.itemIndex;
613-
}
614595
else
615596
{
616597
/*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
10001000
so->currPos.moreRight= false;
10011001
}
10021002
so->numKilled=0;/* just paranoia */
1003-
so->markItemIndex=-1;/* ditto */
1003+
Assert(so->markItemIndex==-1);
10041004

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp