Skip to content

Commit

Permalink
get avoid snapshot interval calculate int overflow (apache#1088)
Browse files Browse the repository at this point in the history
Signed-off-by: Andy.Chen <[email protected]>
  • Loading branch information
Roiocam committed Feb 1, 2024
1 parent 1bc11b1 commit 7ea162e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ import pekko.persistence.typed.scaladsl

def deleteUpperSequenceNr(lastSequenceNr: Long): Long = {
// Delete old events, retain the latest
math.max(0, lastSequenceNr - (keepNSnapshots * snapshotEveryNEvents))
math.max(0, lastSequenceNr - (keepNSnapshots.toLong * snapshotEveryNEvents))
}

def deleteLowerSequenceNr(upperSequenceNr: Long): Long = {
// We could use 0 as fromSequenceNr to delete all older snapshots, but that might be inefficient for
// large ranges depending on how it's implemented in the snapshot plugin. Therefore we use the
// same window as defined for how much to keep in the retention criteria
math.max(0, upperSequenceNr - (keepNSnapshots * snapshotEveryNEvents))
math.max(0, upperSequenceNr - (keepNSnapshots.toLong * snapshotEveryNEvents))
}

override def withDeleteEventsOnSnapshot: SnapshotCountRetentionCriteriaImpl =
Expand Down

0 comments on commit 7ea162e

Please sign in to comment.