59
59
// servers, ordered by how much data they are pinning, below which a server
60
60
// will pin underpinned skylinks.
61
61
PinningRangeThresholdPercent = 0.30
62
- // SleepBetweenPins defines how long we'll sleep between pinning files.
63
- // We want to add this sleep in order to prevent a single server from
64
- // grabbing all underpinned files and overloading itself. We also want to
65
- // allow for some time for the newly pinned files to reach full redundancy
66
- // before we pin more files.
67
- SleepBetweenPins = build .Select (
68
- build.Var {
69
- Standard : 10 * time .Second ,
70
- Dev : time .Second ,
71
- Testing : time .Millisecond ,
72
- }).(time.Duration )
73
62
// SleepBetweenHealthChecks defines the wait time between calls to skyd to
74
63
// check the current health of a given file.
75
64
SleepBetweenHealthChecks = build .Select (
@@ -79,14 +68,20 @@ var (
79
68
Testing : time .Millisecond ,
80
69
}).(time.Duration )
81
70
71
+ // minDeadline defines the minimum time we're going to wait for a skylink to
72
+ // reach full health before timing out.
73
+ minDeadline = build .Select (build.Var {
74
+ Standard : 30 * time .Second ,
75
+ Dev : time .Second ,
76
+ Testing : time .Millisecond ,
77
+ }).(time.Duration )
82
78
// printPinningStatisticsPeriod defines how often we print intermediate
83
79
// statistics while pinning underpinned files.
84
80
printPinningStatisticsPeriod = build .Select (build.Var {
85
81
Standard : 10 * time .Minute ,
86
82
Dev : 10 * time .Second ,
87
83
Testing : 500 * time .Millisecond ,
88
84
}).(time.Duration )
89
-
90
85
// sleepBetweenScans defines how often we'll scan the DB for underpinned
91
86
// skylinks.
92
87
// Needs to be at least twice as long as conf.SleepBetweenChecksForScan.
@@ -399,15 +394,6 @@ func (s *Scanner) managedPinUnderpinnedSkylinks() {
399
394
s .staticWaitUntilHealthy (skylink , sp )
400
395
continue
401
396
}
402
- // In case of error we still want to sleep for a moment in order to
403
- // avoid a tight(ish) loop of errors when we either fail to pin or
404
- // fail to mark as pinned. Note that this only happens when we want
405
- // to continue scanning, otherwise we would have exited right after
406
- // managedFindAndPinOneUnderpinnedSkylink.
407
- stopped := s .staticSleepForOrUntilStopped (SleepBetweenPins )
408
- if stopped {
409
- return
410
- }
411
397
}
412
398
}
413
399
@@ -522,7 +508,8 @@ func (s *Scanner) staticEstimateTimeToFull(skylink skymodules.Skylink) time.Dura
522
508
if err != nil {
523
509
err = errors .AddContext (err , "failed to get metadata for skylink" )
524
510
s .staticLogger .Error (err )
525
- return SleepBetweenPins
511
+ // No metadata. Return some ballpark value that makes sense.
512
+ return SleepBetweenHealthChecks
526
513
}
527
514
chunkSize := 10 * modules .SectorSizeStandard
528
515
numChunks := meta .Length / chunkSize
@@ -657,5 +644,9 @@ func (s *Scanner) staticSleepForOrUntilStopped(dur time.Duration) bool {
657
644
// healthy before giving up. It's twice the expected time, as returned by
658
645
// staticEstimateTimeToFull.
659
646
func (s * Scanner ) staticDeadline (skylink skymodules.Skylink ) * time.Timer {
660
- return time .NewTimer (2 * s .staticEstimateTimeToFull (skylink ))
647
+ deadline := 2 * s .staticEstimateTimeToFull (skylink )
648
+ if deadline < minDeadline {
649
+ deadline = minDeadline
650
+ }
651
+ return time .NewTimer (deadline )
661
652
}
0 commit comments