Skip to content

Commit

Permalink
Randomize delay after each scrub instead of once at start
Browse files Browse the repository at this point in the history
  • Loading branch information
sio committed May 24, 2024
1 parent 8dd0545 commit f7494d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nbd/s3/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ func (c *Cache) bgIntegrity(checksum verity.Verity) {
sleep := time.After(time.Hour + rand.N(10*time.Minute))

// Delay before each consecutive scrub after that
delayBetweenScrubs := 3*time.Hour + rand.N(10*time.Minute)
delayBetweenScrubs := func() time.Time {
return 3*time.Hour + rand.N(10*time.Minute)
}

log := logger.FromContext(c.ctx)
var part chunk
Expand All @@ -283,7 +285,7 @@ func (c *Cache) bgIntegrity(checksum verity.Verity) {
if !ok {
// No more chunks to check, wait for a while and start from the beginning
part = 0
sleep = time.After(delayBetweenScrubs)
sleep = time.After(delayBetweenScrubs())
}
}
}
Expand Down

0 comments on commit f7494d7

Please sign in to comment.