mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #3311 from yichengq/request-timeout
extend hardcoded timeout for globally-deployed etcd cluster
This commit is contained in:
commit
bcb4d5d53e
@ -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
|
||||||
|
}
|
||||||
|
@ -215,7 +215,6 @@ func isCompatibleWithVers(vers map[string]*version.Versions, local types.ID, min
|
|||||||
func getVersion(m *Member, tr *http.Transport) (*version.Versions, error) {
|
func getVersion(m *Member, tr *http.Transport) (*version.Versions, error) {
|
||||||
cc := &http.Client{
|
cc := &http.Client{
|
||||||
Transport: tr,
|
Transport: tr,
|
||||||
Timeout: time.Second,
|
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
@ -842,7 +842,8 @@ func mustNewHTTPClient(t *testing.T, eps []string) client.Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mustNewTransport(t *testing.T, tlsInfo transport.TLSInfo) *http.Transport {
|
func mustNewTransport(t *testing.T, tlsInfo transport.TLSInfo) *http.Transport {
|
||||||
tr, err := transport.NewTimeoutTransport(tlsInfo, rafthttp.DialTimeout, rafthttp.ConnReadTimeout, rafthttp.ConnWriteTimeout)
|
// tick in integration test is short, so 1s dial timeout could play well.
|
||||||
|
tr, err := transport.NewTimeoutTransport(tlsInfo, time.Second, rafthttp.ConnReadTimeout, rafthttp.ConnWriteTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DialTimeout = time.Second
|
|
||||||
// ConnRead/WriteTimeout is the i/o timeout set on each connection rafthttp pkg creates.
|
// ConnRead/WriteTimeout is the i/o timeout set on each connection rafthttp pkg creates.
|
||||||
// A 5 seconds timeout is good enough for recycling bad connections. Or we have to wait for
|
// A 5 seconds timeout is good enough for recycling bad connections. Or we have to wait for
|
||||||
// tcp keepalive failing to detect a bad connection, which is at minutes level.
|
// tcp keepalive failing to detect a bad connection, which is at minutes level.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user