File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -526,6 +526,21 @@ assert p x = Exc.assert p (const x callStack)
526526assertST :: HasCallStack => Bool -> ST s ()
527527assertST p = assert p $ pure ()
528528
529+ assertWithMsg :: HasCallStack => Maybe String -> a -> a
530+ assertWithMsg = assert . p
531+ where
532+ p Nothing = True
533+ p (Just msg) = error $ " Assertion failed: " <> msg
534+
535+ assertWithMsgM :: (HasCallStack , Monad m ) => Maybe String -> m ()
536+ assertWithMsgM mmsg = assertWithMsg mmsg $ pure ()
537+
538+ leq :: (Show a , Ord a ) => a -> a -> Maybe String
539+ leq x y = if x <= y then Nothing else Just $
540+ printf " Expected x <= y, but got %s > %s"
541+ (show x)
542+ (show y)
543+
529544-------------------------------------------------------------------------------
530545-- Run sizes
531546--
@@ -1461,7 +1476,7 @@ newLevelMerge _ _ _ _ _ [r] = pure (Single r)
14611476newLevelMerge tr conf@ LSMConfig {.. } level mergePolicy mergeType rs = do
14621477 assertST (length rs `elem` [configSizeRatio, configSizeRatio + 1 ])
14631478 mergingRun@ (MergingRun _ physicalDebt _) <- newMergingRun mergeType rs
1464- assertST (totalDebt physicalDebt <= maxPhysicalDebt)
1479+ assertWithMsgM $ leq (totalDebt physicalDebt) maxPhysicalDebt
14651480 traceWith tr MergeStartedEvent {
14661481 mergePolicy,
14671482 mergeType,
You can’t perform that action at this time.
0 commit comments