Rather than crashing when there's a problem with the requested bloomfilter capacity/accuracy, fall back to a reasonable default bloom filter size.

This commit is contained in:
Joey Hess 2014-09-12 12:26:12 -04:00
parent eb26f00c04
commit 7482166180
3 changed files with 10 additions and 3 deletions

View file

@ -189,7 +189,12 @@ bloomBitsHashes :: Annex (Int, Int)
bloomBitsHashes = do bloomBitsHashes = do
capacity <- bloomCapacity capacity <- bloomCapacity
accuracy <- bloomAccuracy accuracy <- bloomAccuracy
return $ suggestSizing capacity (1/ fromIntegral accuracy) case safeSuggestSizing capacity (1 / fromIntegral accuracy) of
Left e -> do
warning $ "bloomfilter " ++ e ++ "; falling back to sane value"
-- precaulculated value for 500000 (1/1000)
return (8388608,10)
Right v -> return v
{- Creates a bloom filter, and runs an action, such as withKeysReferenced, {- Creates a bloom filter, and runs an action, such as withKeysReferenced,
- to populate it. - to populate it.

View file

@ -9,7 +9,7 @@
module Utility.Bloom ( module Utility.Bloom (
Bloom, Bloom,
suggestSizing, safeSuggestSizing,
Hashable, Hashable,
cheapHashes, cheapHashes,
notElemB, notElemB,
@ -25,7 +25,7 @@ import qualified Data.BloomFilter as Bloom
#else #else
import qualified Data.BloomFilter as Bloom import qualified Data.BloomFilter as Bloom
#endif #endif
import Data.BloomFilter.Easy (suggestSizing, Bloom) import Data.BloomFilter.Easy (safeSuggestSizing, Bloom)
import Data.BloomFilter.Hash (Hashable, cheapHashes) import Data.BloomFilter.Hash (Hashable, cheapHashes)
import Control.Monad.ST.Safe (ST) import Control.Monad.ST.Safe (ST)

2
debian/changelog vendored
View file

@ -20,6 +20,8 @@ git-annex (5.20140832) UNRELEASED; urgency=medium
the repository, rather than just the file's base name. Note that if you're the repository, rather than just the file's base name. Note that if you're
relying on such things to keep files separate with WORM, you should really relying on such things to keep files separate with WORM, you should really
be using a better backend. be using a better backend.
* Rather than crashing when there's a problem with the requested bloomfilter
capacity/accuracy, fall back to a reasonable default bloom filter size.
-- Joey Hess <joeyh@debian.org> Thu, 04 Sep 2014 16:17:22 -0400 -- Joey Hess <joeyh@debian.org> Thu, 04 Sep 2014 16:17:22 -0400