mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #265 from xiangli-cmu/fix-timeout
headerTimeout should be longer and body should be shorter
This commit is contained in:
commit
378c3d1dcf
@ -18,13 +18,15 @@ import (
|
|||||||
// This should not exceed 3 * RTT
|
// This should not exceed 3 * RTT
|
||||||
var dailTimeout = 3 * HeartbeatTimeout
|
var dailTimeout = 3 * HeartbeatTimeout
|
||||||
|
|
||||||
// Timeout for setup internal raft http connection + receive response header
|
// Timeout for setup internal raft http connection + receive all post body
|
||||||
// This should not exceed 3 * RTT + RTT
|
// The raft server will not send back response header until it received all the
|
||||||
var responseHeaderTimeout = 4 * HeartbeatTimeout
|
// post body.
|
||||||
|
// This should not exceed dailTimeout + electionTimeout
|
||||||
|
var responseHeaderTimeout = 3*HeartbeatTimeout + ElectionTimeout
|
||||||
|
|
||||||
// Timeout for receiving the response body from the server
|
// Timeout for receiving the response body from the server
|
||||||
// This should not exceed election timeout
|
// This should not exceed heartbeatTimeout
|
||||||
var tranTimeout = ElectionTimeout
|
var tranTimeout = HeartbeatTimeout
|
||||||
|
|
||||||
// Transporter layer for communication between raft nodes
|
// Transporter layer for communication between raft nodes
|
||||||
type transporter struct {
|
type transporter struct {
|
||||||
@ -221,7 +223,7 @@ func (t *transporter) Get(urlStr string) (*http.Response, *http.Request, error)
|
|||||||
// Cancel the on fly HTTP transaction when timeout happens.
|
// Cancel the on fly HTTP transaction when timeout happens.
|
||||||
func (t *transporter) CancelWhenTimeout(req *http.Request) {
|
func (t *transporter) CancelWhenTimeout(req *http.Request) {
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(ElectionTimeout)
|
time.Sleep(tranTimeout)
|
||||||
t.transport.CancelRequest(req)
|
t.transport.CancelRequest(req)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user