]> granicus.if.org Git - postgresql/commit
Don't rely on estimates for amcheck Bloom filters.
authorPeter Geoghegan <pg@bowt.ie>
Sat, 20 Jul 2019 18:11:54 +0000 (11:11 -0700)
committerPeter Geoghegan <pg@bowt.ie>
Sat, 20 Jul 2019 18:11:54 +0000 (11:11 -0700)
commit980224b4a23056de76d902b539980868d33d1b8d
tree0b8bc45e70ce4f8507bc99f780ddf0adae7ced62
parent5a8ee9f2dbe040b9a0cb7f73a4376633f93b4ab4
Don't rely on estimates for amcheck Bloom filters.

Solely relying on a relation's reltuples/relpages estimate to size the
Bloom filters used by amcheck verification makes verification less
effective when the estimates are very stale.  In extreme cases,
verification options that use Bloom filters internally could be totally
ineffective, without users receiving any clear indication that certain
types of corruption might easily be missed.

To fix, use RelationGetNumberOfBlocks() instead of relpages to size the
downlink 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 be
reasonably effective when the projected/estimated number of Bloom filter
elements is at least 1/5 of the final number of elements, which is
assured by the new sizing logic.

Reported-By: Alexander Korotkov
Discussion: https://postgr.es/m/CAH2-Wzk0ke2J42KrNYBKu0Xovjy-sU5ub7PWjgpbsKdAQcL4OA@mail.gmail.com
Backpatch: 11-, where downlink/heapallindexed verification were added.
contrib/amcheck/verify_nbtree.c