Skip to content

Commit

Permalink
v3rpc: add jitter to progress notification
Browse files Browse the repository at this point in the history
  • Loading branch information
xiang90 committed Feb 5, 2018
1 parent 07f9229 commit f6a0a44
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion etcdserver/api/v3rpc/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package v3rpc
import (
"context"
"io"
"math/rand"
"sync"
"time"

Expand Down Expand Up @@ -58,7 +59,9 @@ var (
func GetProgressReportInterval() time.Duration {
progressReportIntervalMu.RLock()
defer progressReportIntervalMu.RUnlock()
return progressReportInterval
// add rand(1/10*progressReportInterval) as jitter so that etcdserver will not
// send progress notification to watches around the same time.
return progressReportInterval + time.Duration(rand.Int63n(int64(progressReportInterval)/10))
}

func SetProgressReportInterval(newTimeout time.Duration) {
Expand Down

0 comments on commit f6a0a44

Please sign in to comment.