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

Commit23607a8

Browse files
committed
Don't add non-existent pages to bitmap from BRIN
The code in bringetbitmap() simply added the whole matching page rangeto the TID bitmap, as determined by pages_per_range, even if some of thepages were beyond the end of the heap. The query then might fail withan error like this: ERROR: could not open file "base/20176/20228.2" (target block 262144): previous segment is only 131021 blocksIn this case, the relation has 262093 pages (131072 and 131021 pages),but we're trying to acess block 262144, i.e. first block of the 3rdsegment. At that point _mdfd_getseg() notices the preceding segment isincomplete, and fails.Hitting this in practice is rather unlikely, because:* Most indexes use power-of-two ranges, so segments and page ranges align perfectly (segment end is also a page range end).* The table size has to be just right, with the last segment being almost full - less than one page range from full segment, so that the last page range actually crosses the segment boundary.* Prefetch has to be enabled. The regular page access checks that pages are not beyond heap end, but prefetch does not. On older releases (before 12) the execution stops after hitting the first non-existent page, so the prefetch distance has to be sufficient to reach the first page in the next segment to trigger the issue. Since 12 it's enough to just have prefetch enabled, the prefetch distance does not matter.Fixed by not adding non-existent pages to the TID bitmap. Backpatchall the way back to 9.6 (BRIN indexes were introduced in 9.5, but thatrelease is EOL).Backpatch-through: 9.6
1 parent5c55dc8 commit23607a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎src/backend/access/brin/brin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
696696
BlockNumberpageno;
697697

698698
for (pageno=heapBlk;
699-
pageno <=heapBlk+opaque->bo_pagesPerRange-1;
699+
pageno <=Min(nblocks,heapBlk+opaque->bo_pagesPerRange)-1;
700700
pageno++)
701701
{
702702
MemoryContextSwitchTo(oldcxt);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp