Skip to content

Commit 2783e7c

Browse files
committed
Issue #752: try to fix forgotten reference
Since I can't reproduce the bug but it has popped up twice now, I've tried to fix the test by making sure that we use `bracket`s everywhere. Hopefully that is the fix.
1 parent 44f7285 commit 2783e7c

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

test/Test/Database/LSMTree/UnitTests.hs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
module Test.Database.LSMTree.UnitTests (tests) where
55

6+
import Control.Exception (Exception, bracket, try)
7+
import Control.Monad (void)
68
import Control.Tracer (nullTracer)
79
import Data.ByteString (ByteString)
810
import qualified Data.ByteString.Char8 as BS
@@ -11,13 +13,10 @@ import Data.List.NonEmpty (NonEmpty (..))
1113
import qualified Data.Map as Map
1214
import qualified Data.Vector as V
1315
import Data.Word
14-
import qualified System.FS.API as FS
15-
1616
import Database.LSMTree as R
17-
18-
import Control.Exception (Exception, bracket, try)
1917
import Database.LSMTree.Extras.Generators ()
2018
import Database.LSMTree.Internal.Serialise (SerialisedKey)
19+
import qualified System.FS.API as FS
2120
import qualified Test.QuickCheck.Arbitrary as QC
2221
import qualified Test.QuickCheck.Gen as QC
2322
import Test.Tasty (TestTree, testGroup)
@@ -222,24 +221,20 @@ unit_union_credit_0 =
222221
unit_union_blobref_invalidation :: Assertion
223222
unit_union_blobref_invalidation =
224223
withTempIOHasBlockIO "test" $ \hfs hbio ->
225-
withOpenSession nullTracer hfs hbio testSalt (FS.mkFsPath []) $ \sess -> do
226-
t1 <- newTableWith @_ @Key1 @Value1 @Blob1 config sess
224+
withOpenSession nullTracer hfs hbio testSalt (FS.mkFsPath []) $ \sess ->
225+
withTableWith config sess $ \t1 -> do
227226
for_ ([0..99] :: [Word64]) $ \i ->
228227
inserts t1 [(Key1 i, Value1 i, Just (Blob1 i))]
229-
t2 <- t1 `union` t1
230-
231-
-- do lookups on the union table (the result contains blob refs)
232-
res <- lookups t2 (Key1 <$> [0..99])
228+
withUnion t1 t1 $ \t2 -> do
229+
-- do lookups on the union table (the result contains blob refs)
230+
res <- lookups t2 (Key1 <$> [0..99])
233231

234-
-- progress original table (supplying merge credits would be most direct),
235-
-- so merges complete
236-
inserts t1 (fmap (\i -> (Key1 i, Value1 i, Nothing)) [1000..2000])
237-
-- closeTable it, so it doesn't hold open extra references
238-
closeTable t1
232+
-- progress original table (supplying merge credits would be most direct),
233+
-- so merges complete
234+
inserts t1 (fmap (\i -> (Key1 i, Value1 i, Nothing)) [1000..2000])
239235

240-
-- try to resolve the blob refs we obtained earlier
241-
_blobs <- retrieveBlobs sess (V.mapMaybe R.getBlob res)
242-
pure ()
236+
-- try to resolve the blob refs we obtained earlier
237+
void $ retrieveBlobs sess (V.mapMaybe R.getBlob res)
243238
where
244239
config = defaultTableConfig {
245240
confWriteBufferAlloc = AllocNumEntries 4

0 commit comments

Comments
 (0)