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

Commit894af78

Browse files
Don't rely on estimates for amcheck Bloom filters.
Solely relying on a relation's reltuples/relpages estimate to size theBloom filters used by amcheck verification makes verification lesseffective when the estimates are very stale. In extreme cases,verification options that use Bloom filters internally could be totallyineffective, without users receiving any clear indication that certaintypes of corruption might easily be missed.To fix, use RelationGetNumberOfBlocks() instead of relpages to size thedownlink block Bloom filter. Use the same RelationGetNumberOfBlocks()value to derive a minimum size for the heapallindexed Bloom filter,rather than completely trusting reltuples. Verification will still bereasonably effective when the projected/estimated number of Bloom filterelements is at least 1/5 of the final number of elements, which isassured by the new sizing logic.Reported-By: Alexander KorotkovDiscussion:https://postgr.es/m/CAH2-Wzk0ke2J42KrNYBKu0Xovjy-sU5ub7PWjgpbsKdAQcL4OA@mail.gmail.comBackpatch: 11-, where downlink/heapallindexed verification were added.
1 parenta63378a commit894af78

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

‎contrib/amcheck/verify_nbtree.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,20 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
377377

378378
if (state->heapallindexed)
379379
{
380+
int64total_pages;
380381
int64total_elems;
381382
uint64seed;
382383

383-
/* Size Bloom filter based on estimated number of tuples in index */
384-
total_elems= (int64)state->rel->rd_rel->reltuples;
384+
/*
385+
* Size Bloom filter based on estimated number of tuples in index,
386+
* while conservatively assuming that each block must contain at least
387+
* MaxIndexTuplesPerPage / 5 non-pivot tuples. (Non-leaf pages cannot
388+
* contain non-pivot tuples. That's okay because they generally make
389+
* up no more than about 1% of all pages in the index.)
390+
*/
391+
total_pages=RelationGetNumberOfBlocks(rel);
392+
total_elems=Max(total_pages* (MaxIndexTuplesPerPage /5),
393+
(int64)state->rel->rd_rel->reltuples);
385394
/* Random seed relies on backend srandom() call to avoid repetition */
386395
seed=random();
387396
/* Create Bloom filter to fingerprint index */
@@ -425,8 +434,6 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
425434
}
426435
else
427436
{
428-
int64total_pages;
429-
430437
/*
431438
* Extra readonly downlink check.
432439
*
@@ -437,7 +444,6 @@ bt_check_every_level(Relation rel, Relation heaprel, bool heapkeyspace,
437444
* splits and page deletions, though. This is taken care of in
438445
* bt_downlink_missing_check().
439446
*/
440-
total_pages= (int64)state->rel->rd_rel->relpages;
441447
state->downlinkfilter=bloom_create(total_pages,work_mem,seed);
442448
}
443449
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp