Skip to content

Commit 5eff96e

Browse files
committed
fix run size invariants that were too tight
1 parent 839c7be commit 5eff96e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

prototypes/ScheduledMerges.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ invariant = go 1
192192
-- too large and is promoted, in that case initially there's no merge,
193193
-- but it is still represented as a 'MergingRun', using 'SingleRun'.
194194
MergePolicyLevelling -> assertST $ null rs
195-
MergePolicyTiering -> assertST $ all (\r -> tieringRunSizeToLevel r == ln) rs
195+
-- Runs in tiering levels usually fit that size, but they can be one
196+
-- larger, if a run has been held back (creating a 5-way merge).
197+
MergePolicyTiering -> assertST $ all (\r -> tieringRunSizeToLevel r `elem` [ln, ln+1]) rs
196198

197199
-- Incoming runs being merged also need to be of the right size, but the
198200
-- conditions are more complicated.
@@ -240,9 +242,10 @@ invariant = go 1
240242

241243
-- A completed mid level run is usually of the size for the
242244
-- level it is entering, but can also be one smaller (in which case
243-
-- it'll be held back and merged again).
245+
-- it'll be held back and merged again) or one larger (because it
246+
-- includes a run that has been held back before).
244247
(_, CompletedMerge r, MergeMidLevel) ->
245-
assertST $ tieringRunSizeToLevel r `elem` [ln, ln+1]
248+
assertST $ tieringRunSizeToLevel r `elem` [ln-1, ln, ln+1]
246249

247250
-- An ongoing merge for tiering should have 4 incoming runs of
248251
-- the right size for the level below, and at most 1 run held back

0 commit comments

Comments
 (0)