lib/model: Don't increase pull pause on triggered pull (#6690)

This commit is contained in:
Simon Frei 2020-05-29 09:52:28 +02:00 committed by GitHub
parent 04ff890263
commit ed6bfc5417
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 12 deletions

View File

@ -148,7 +148,10 @@ func (f *folder) serve(ctx context.Context) {
f.pull()
case <-f.pullFailTimer.C:
f.pull()
if !f.pull() && f.pullPause < 60*f.pullBasePause() {
// Back off from retrying to pull
f.pullPause *= 2
}
case <-initialCompleted:
// Initial scan has completed, we should do a pull
@ -276,7 +279,7 @@ func (f *folder) getHealthErrorWithoutIgnores() error {
return nil
}
func (f *folder) pull() bool {
func (f *folder) pull() (success bool) {
f.pullFailTimer.Stop()
select {
case <-f.pullFailTimer.C:
@ -290,6 +293,13 @@ func (f *folder) pull() bool {
return true
}
defer func() {
if success {
// We're good, reset the pause interval.
f.pullPause = f.pullBasePause()
}
}()
// If there is nothing to do, don't even enter sync-waiting state.
abort := true
snap := f.fset.Snapshot()
@ -312,24 +322,16 @@ func (f *folder) pull() bool {
startTime := time.Now()
success := f.puller.pull()
basePause := f.pullBasePause()
success = f.puller.pull()
if success {
// We're good. Don't schedule another pull and reset
// the pause interval.
f.pullPause = basePause
return true
}
// Pulling failed, try again later.
delay := f.pullPause + time.Since(startTime)
l.Infof("Folder %v isn't making sync progress - retrying in %v.", f.Description(), delay)
l.Infof("Folder %v isn't making sync progress - retrying in %v.", f.Description(), delay.Truncate(time.Second))
f.pullFailTimer.Reset(delay)
if f.pullPause < 60*basePause {
f.pullPause *= 2
}
return false
}