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

Commit8f72bba

Browse files
Harden nbtree deduplication posting split code.
Add a defensive "can't happen" error to code that handles nbtree postinglist splits (promote an existing assertion). This avoids a segfault inthe event of an insertion of a newitem that is somehow identical to anexisting non-pivot tuple in the index. An nbtree index should neverhave two index tuples with identical TIDs.This scenario is not particular unlikely in the event of any kind ofcorruption that leaves the index in an inconsistent state relative tothe heap relation that is indexed. There are two known reports ofpreventable hard crashes. Doing nothing seems unacceptable given thegeneral expectation that nbtree will cope reasonably well with corruptdata.Discussion:https://postgr.es/m/CAH2-Wz=Jr_d-dOYEEmwz0-ifojVNWho01eAqewfQXgKfoe114w@mail.gmail.comBackpatch: 13-, where nbtree deduplication was introduced.
1 parentc3c35a7 commit8f72bba

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,19 @@ _bt_swap_posting(IndexTuple newitem, IndexTuple oposting, int postingoff)
10241024

10251025
nhtids=BTreeTupleGetNPosting(oposting);
10261026
Assert(_bt_posting_valid(oposting));
1027-
Assert(postingoff>0&&postingoff<nhtids);
1027+
1028+
/*
1029+
* The postingoff argument originated as a _bt_binsrch_posting() return
1030+
* value. It will be 0 in the event of corruption that makes a leaf page
1031+
* contain a non-pivot tuple that's somehow identical to newitem (no two
1032+
* non-pivot tuples should ever have the same TID). This has been known
1033+
* to happen in the field from time to time.
1034+
*
1035+
* Perform a basic sanity check to catch this case now.
1036+
*/
1037+
if (!(postingoff>0&&postingoff<nhtids))
1038+
elog(ERROR,"posting list tuple with %d items cannot be split at offset %d",
1039+
nhtids,postingoff);
10281040

10291041
/*
10301042
* Move item pointers in posting list to make a gap for the new item's

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp