Skip to content

Commit

Permalink
agent: Adding random stagger to anti-entropy. Fixes #72.
Browse files Browse the repository at this point in the history
  • Loading branch information
armon committed Apr 23, 2014
1 parent 02fa6e9 commit 903789a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions command/agent/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
)

const (
syncRetryIntv = 30 * time.Second
syncStaggerIntv = 3 * time.Second
syncRetryIntv = 15 * time.Second
)

// syncStatus is used to represent the difference between
Expand Down Expand Up @@ -223,7 +224,13 @@ SYNC:
l.logger.Printf("[ERR] agent: failed to sync remote state: %v", err)
select {
case <-l.consulCh:
case <-time.After(aeScale(syncRetryIntv, len(l.iface.LANMembers()))):
// Stagger the retry on leader election, avoid a thundering heard
select {
case <-time.After(randomStagger(aeScale(syncStaggerIntv, len(l.iface.LANMembers())))):
case <-shutdownCh:
return
}
case <-time.After(randomStagger(aeScale(syncRetryIntv, len(l.iface.LANMembers())))):
case <-shutdownCh:
return
}
Expand Down

0 comments on commit 903789a

Please sign in to comment.