agent: Adding random stagger to anti-entropy. Fixes #72.

This commit is contained in:
Armon Dadgar 2014-04-23 12:21:34 -07:00
parent 02fa6e9d96
commit 903789aee4
1 changed files with 9 additions and 2 deletions

View File

@ -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
@ -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
}