Skip to content

Commit

Permalink
fix(journal): check for backpressure before rotation
Browse files Browse the repository at this point in the history
Thanks Daniel!
  • Loading branch information
symbiont-stevan-andjelkovic committed Feb 4, 2022
1 parent 1f22f3b commit 30ef619
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/journal/test/JournalTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ appendBSFake bs fj@(FakeJournal bss ix termCount) =
, "position: " ++ show position
, "limit: " ++ show limit
]) $
if journalLength >= termLen * termCount
then (FakeJournal (Vector.snoc bss padd) ix (termCount + 1), Left Rotation)
else if position < limit
then (FakeJournal (Vector.snoc bss bs) ix termCount, Right ())
if position < limit
then if journalLength >= termLen * termCount
then (FakeJournal (Vector.snoc bss padding) ix (termCount + 1), Left Rotation)
else (FakeJournal (Vector.snoc bss bs) ix termCount, Right ())
else (fj, Left BackPressure)
where
journalLength :: Int
journalLength = sum (Vector.map (\bs -> hEADER_LENGTH + BS.length bs) bss)
+ hEADER_LENGTH + BS.length bs

padd :: ByteString
padd = BS.replicate (termLen * termCount - journalLength) '0'
padding :: ByteString
padding = BS.replicate (termLen * termCount - journalLength) '0'

termLen :: Int
termLen = oTermBufferLength testOptions
Expand Down

0 comments on commit 30ef619

Please sign in to comment.