Skip to content

Commit

Permalink
Larger delay on mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Oct 27, 2016
1 parent 962f4d4 commit 0efab91
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion nomad/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const (
// the slower backoff
backoffLimitSlow = 10 * time.Second

// backoffSchedulerVersionMismatch is the backoff between retries when the
// scheduler version mismatches that of the leader.
backoffSchedulerVersionMismatch = 30 * time.Second

// dequeueTimeout is used to timeout an evaluation dequeue so that
// we can check if there is a shutdown event
dequeueTimeout = 500 * time.Millisecond
Expand Down Expand Up @@ -155,7 +159,16 @@ REQ:
if time.Since(w.start) > dequeueErrGrace && !w.srv.IsShutdown() {
w.logger.Printf("[ERR] worker: failed to dequeue evaluation: %v", err)
}
if w.backoffErr(backoffBaselineSlow, backoffLimitSlow) {

// Adjust the backoff based on the error. If it is a scheduler version
// mismatch we increase the baseline.
base, limit := backoffBaselineFast, backoffLimitSlow
if strings.Contains(err.Error(), "calling scheduler version") {
base = backoffSchedulerVersionMismatch
limit = backoffSchedulerVersionMismatch
}

if w.backoffErr(base, limit) {
return nil, "", true
}
goto REQ
Expand Down

0 comments on commit 0efab91

Please sign in to comment.