IntersectMBO / IntersectMBO/lsm-tree
[BUG] `NoThunks` assertions failures when using `modifyMVarMasked`
- Dominant language
- Haskell
- Stars
- 53
- Forks
- 17
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 4
Description
**Describe the bug**
The use of `strict-mvar`'s `modifyMVarMasked_` and `modifyMVarMasked` functions in the `Database.LSMTree.Internal.MergeSchedule` module make our `NoThunks` tests fail. We start to use these functions in #426, and subsequently `NoThunks` assertions started failing. As part of #426, the assertions are temporarily disabled.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to `Test.Database.LSMTree.Normal.StateMachine.runIO`
2. Replace the line `const id (assertNoThunks sesh) $ pure ()` by `assertNoThunks sesh $ pure ()`
3. Run `cabal run lsm-tree-test -- -p '$NF=="propLockstep_RealImpl_MockFS_IO"'`
**Expected behavior**
These `strict-mvar` functions are expected to be strict enough to not leave any (shallow) thunks in our code. We should investigate why the `NoThunks` assertions fail, and then enable them again.
**Output**
```
❯ cabal run lsm-tree-test -- -p '$NF=="propLockstep_RealImpl_MockFS_IO"'
lsm-tree
Normal.StateMachine
propLockstep_RealImpl_MockFS_IO: FAIL (4.87s)
*** Failed! (after 27 tests and 79 shrinks):
Exception:
Assertion failed: found thunkThunkInfo {thunkContext = ["MergingRunState","StrictMVar IO","MergingRun","incomingRuns","Level","Boxed.Vector","tableLevels","TableContent","RWState","StrictTVar IO","RWVar","tableContent","TableHandleEnv IO HandleMock","TableHandleState","RWState","StrictTVar IO","RWVar","tableHandleState","TableHandle","Map","StrictMVar IO","sessionOpenTables","SessionEnv","SessionState","RWState","StrictTVar IO","RWVar","sessionState","Session'"], thunkInfo = Nothing}
CallStack (from HasCallStack):
error, called at src-extras/Database/LSMTree/Extras/NoThunks.hs:75:33 in lsm-tree-0.1.0.0-inplace-extras:Database.LSMTree.Extras.NoThunks
do var26 <- action $ New (PrettyProxy @((Key1,Value1,Blob1))) (TableConfig {confMergePolicy = MergePolicyLazyLevelling, confSizeRatio = Four, confWriteBufferAlloc = AllocNumEntries (NumEntries 5), confBloomFilterAlloc = AllocFixed 10, confFencePointerIndex = CompactIndex, confDiskCachePolicy = DiskCacheNone, confMergeSchedule = Incremental})
action $ Updates [(Key1 {_unKey1 = Small {getSmall = 0}},Delete),(Key1 {_unKey1 = Small {getSmall = 1}},Delete),(Key1 {_unKey1 = Small {getSmall = 3}},Delete),(Key1 {_unKey1 = Small {getSmall = 4}},Delete),(Key1 {_unKey1 = Small {getSmall = 2}},Delete),(Key1 {_unKey1 = Small {getSmall = 0}},Delete),(Key1 {_unKey1 = Small {getSmall = 2}},Delete),(Key1 {_unKey1 = Small {getSmall = 3}},Delete),(Key1 {_unKey1 = Small {getSmall = 4}},Delete),(Key1 {_unKey1 = Small {getSmall = 1}},Delete),(Key1 {_unKey1 = Small {getSmall = 0}},Delete),(Key1 {_unKey1 = Small {getSmall = 2}},Delete),(Key1 {_unKey1 = Small {getSmall = 3}},Delete),(Key1 {_unKey1 = Small {getSmall = 4}},Delete),(Key1 {_unKey1 = Small {getSmall = 1}},Delete),(Key1 {_unKey1 = Small {getSmall = 0}},Delete),(Key1 {_unKey1 = Small {getSmall = 2}},Delete),(Key1 {_unKey1 = Small {getSmall = 3}},Delete),(Key1 {_unKey1 = Small {getSmall = 4}},Delete)] (unsafeMkGVar var26 (FromRight . id))
action $ Updates [(Key1 {_unKey1 = Small {getSmall = 1}},Delete),(Key1 {_unKey1 = Small {getSmall = 0}},Delete),(Key1 {_unKey1 = Small {getSmall = 1}},Delete),(Key1 {_unKey1 = Small {getSmall = 2}},Delete),(Key1 {_unKey1 = Small {getSmall = 3}},Delete),(Key1 {_unKey1 = Small {getSmall = 4}},Delete),(Key1 {_unKey1 = Small {getSmall = 0}},Delete),(Key1 {_unKey1 = Small {getSmall = 1}},Delete),(Key1 {_unKey1 = Small {getSmall = 2}},Delete),(Key1 {_unKey1 = Small {getSmall = 3}},Delete)] (unsafeMkGVar var26 (FromRight . id))
pure ()
Use --quickcheck-replay="(SMGen 14857188722218918723 2942465459729247775,26)" to reproduce.
1 out of 1 tests failed (4.87s)
```
**Desktop (please complete the following information):**
- OS: Ubuntu
- OS version: 22.04
- GHC: ghc-9.6.6
Contributor guide
Assessment
This issue has not been assessed yet.