From 230323255aedf12d515b6b5e85ed757ab37169f2 Mon Sep 17 00:00:00 2001 From: Xiang Date: Fri, 22 Sep 2017 14:55:52 -0700 Subject: [PATCH 1/2] etcdserver: make dial timeout longer --- etcdserver/config.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/etcdserver/config.go b/etcdserver/config.go index cac4fb01060..19d1d038c92 100644 --- a/etcdserver/config.go +++ b/etcdserver/config.go @@ -181,9 +181,8 @@ func (c *ServerConfig) electionTimeout() time.Duration { } func (c *ServerConfig) peerDialTimeout() time.Duration { - // 1s for queue wait and system delay - // + one RTT, which is smaller than 1/5 election timeout - return time.Second + time.Duration(c.ElectionTicks)*time.Duration(c.TickMs)*time.Millisecond/5 + // 1s for queue wait and election timeout + return time.Second + time.Duration(c.ElectionTicks)*time.Duration(c.TickMs)*time.Millisecond } func (c *ServerConfig) PrintWithInitial() { c.print(true) } From 35e285674bbf6a3c462c9e8ce48b9b87f442ba39 Mon Sep 17 00:00:00 2001 From: Xiang Date: Fri, 22 Sep 2017 19:35:41 -0700 Subject: [PATCH 2/2] etcdserver: make tick duration calculation clear --- etcdserver/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etcdserver/config.go b/etcdserver/config.go index 19d1d038c92..a6aced9e5b7 100644 --- a/etcdserver/config.go +++ b/etcdserver/config.go @@ -173,16 +173,16 @@ func (c *ServerConfig) ShouldDiscover() bool { return c.DiscoveryURL != "" } func (c *ServerConfig) ReqTimeout() time.Duration { // 5s for queue waiting, computation and disk IO delay // + 2 * election timeout for possible leader election - return 5*time.Second + 2*time.Duration(c.ElectionTicks)*time.Duration(c.TickMs)*time.Millisecond + return 5*time.Second + 2*time.Duration(c.ElectionTicks*int(c.TickMs))*time.Millisecond } func (c *ServerConfig) electionTimeout() time.Duration { - return time.Duration(c.ElectionTicks) * time.Duration(c.TickMs) * time.Millisecond + return time.Duration(c.ElectionTicks*int(c.TickMs)) * time.Millisecond } func (c *ServerConfig) peerDialTimeout() time.Duration { // 1s for queue wait and election timeout - return time.Second + time.Duration(c.ElectionTicks)*time.Duration(c.TickMs)*time.Millisecond + return time.Second + time.Duration(c.ElectionTicks*int(c.TickMs))*time.Millisecond } func (c *ServerConfig) PrintWithInitial() { c.print(true) }