|
@@ -174,7 +174,7 @@ func startEtcd(cfg *config) (<-chan struct{}, error) {
|
|
|
return nil, fmt.Errorf("error setting up initial cluster: %v", err)
|
|
return nil, fmt.Errorf("error setting up initial cluster: %v", err)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- pt, err := transport.NewTimeoutTransport(cfg.peerTLSInfo, rafthttp.DialTimeout, rafthttp.ConnReadTimeout, rafthttp.ConnWriteTimeout)
|
|
|
|
|
|
|
+ pt, err := transport.NewTimeoutTransport(cfg.peerTLSInfo, peerDialTimeout(cfg.ElectionMs), rafthttp.ConnReadTimeout, rafthttp.ConnWriteTimeout)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|
|
@@ -503,3 +503,9 @@ func setupLogging(cfg *config) {
|
|
|
repoLog.SetLogLevel(settings)
|
|
repoLog.SetLogLevel(settings)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func peerDialTimeout(electionMs uint) time.Duration {
|
|
|
|
|
+ // 1s for queue wait and system delay
|
|
|
|
|
+ // + one RTT, which is smaller than 1/5 election timeout
|
|
|
|
|
+ return time.Second + time.Duration(electionMs)*time.Millisecond/5
|
|
|
|
|
+}
|