Skip to content

Commit bb1c820

Browse files
committed
Guard against overflow of exponential
1 parent 3d3b5e4 commit bb1c820

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cardano-db-sync/src/Cardano/DbSync/OffChain/FetchQueue.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ retryAgain fetchTime existingRetryCount =
2828
-- POSIXTime is in seconds.
2929
Retry
3030
{ retryFetchTime = fetchTime
31-
, retryRetryTime = fetchTime + min (24 * 60 * 60) (30 + (5 ^ nextRetryCount) * 60)
31+
, retryRetryTime = fetchTime + retryDiff
3232
, retryCount = nextRetryCount
3333
}
3434
where
3535
nextRetryCount :: Word
3636
nextRetryCount = 1 + existingRetryCount
3737

38+
retryDiff =
39+
if nextRetryCount >= 5
40+
then 24 * 60 * 60
41+
else min (24 * 60 * 60) (30 + (2 ^ nextRetryCount) * 60)
42+
3843
-- A nice pretty printer for the retry.
3944
showRetryTimes :: Retry -> Text
4045
showRetryTimes retry =

0 commit comments

Comments
 (0)