diff options
Diffstat (limited to 'internal/cache/util.go')
-rw-r--r-- | internal/cache/util.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/internal/cache/util.go b/internal/cache/util.go index ba4a43fdd..2d7badf68 100644 --- a/internal/cache/util.go +++ b/internal/cache/util.go @@ -74,8 +74,14 @@ func tryStop[ValueType any](cache *result.Cache[ValueType], sweep time.Duration) func tryUntil(msg string, count int, do func() bool) { for i := 0; i < count; i++ { if do() { + // success. return } + + // Sleep for a little before retry (a bcakoff). + time.Sleep(time.Millisecond * 1 << (i + 1)) } + + // panic on total failure as this shouldn't happen. log.Panicf(nil, "failed %s after %d tries", msg, count) } |