Skip to content

Commit

Permalink
Reduce public root retry timer.
Browse files Browse the repository at this point in the history
Lower the maximum retry timer from above 1h to 4 minutes.
Normally public roots have a ttl of 5s when taken from the ledger. But
for bootstrap peers the ttl from DNS will be returned. Since this can be
hours or days we cap it to 60s and depend on backoff counter to increase
it further if needed.
  • Loading branch information
karknu authored and coot committed May 7, 2024
1 parent 5eaea82 commit ad74301
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ jobReqPublicRootPeers PeerSelectionActions{ requestPublicRootPeers
Completion $ \st now ->
-- This is a failure, so move the backoff counter one in the failure
-- direction (negative) and schedule the next retry time accordingly.
-- We use an exponential backoff strategy. The max retry time of 2^12
-- seconds is just over an hour.
-- We use an exponential backoff strategy. The max retry time of 2^8
-- seconds is about 4 minutes.
let publicRootBackoffs' :: Int
publicRootBackoffs' = (publicRootBackoffs st `min` 0) - 1

publicRootRetryDiffTime' :: DiffTime
publicRootRetryDiffTime' = 2 ^ (abs publicRootBackoffs' `min` 12)
publicRootRetryDiffTime' = 2 ^ (abs publicRootBackoffs' `min` 8)

publicRootRetryTime' :: Time
publicRootRetryTime' = addTime publicRootRetryDiffTime' now
Expand Down Expand Up @@ -146,8 +146,8 @@ jobReqPublicRootPeers PeerSelectionActions{ requestPublicRootPeers
-- below target we're going to want to try again at some point.
-- If we made progress towards our target then we will retry at the
-- suggested ttl. But if we did not make progress then we want to
-- follow an exponential backoff strategy. The max retry time of 2^12
-- seconds is just over an hour.
-- follow an exponential backoff strategy. The max retry time of 2^8
-- seconds is about 4 minutes.
publicRootBackoffs' :: Int
publicRootBackoffs'
| PublicRootPeers.null newPeers = (publicRootBackoffs st `max` 0) + 1
Expand All @@ -156,8 +156,8 @@ jobReqPublicRootPeers PeerSelectionActions{ requestPublicRootPeers
publicRootRetryDiffTime :: DiffTime
publicRootRetryDiffTime
| publicRootBackoffs' == 0
= ttl
| otherwise = 2^(publicRootBackoffs' `min` 12)
= min 60 ttl -- don't let days long dns timeout kreep in here.
| otherwise = 2^(publicRootBackoffs' `min` 8)

publicRootRetryTime :: Time
publicRootRetryTime = addTime publicRootRetryDiffTime now
Expand Down

0 comments on commit ad74301

Please sign in to comment.