Browse Source

etcdserver: use timeout transport as peer transport

This pairs with remote timeout listeners.

etcd uses timeout listener, and times out the accepted connections
if there is no activity. So the idle connections may time out easily.
Becaus timeout transport doesn't reuse connections, it prevents using
timeouted connection.

This fixes the problem that etcd fail to get version of peers.
Yicheng Qin 10 years ago
parent
commit
0eee88a3d9
2 changed files with 4 additions and 2 deletions
  1. 2 1
      etcdserver/server.go
  2. 2 1
      rafthttp/transport.go

+ 2 - 1
etcdserver/server.go

@@ -211,7 +211,8 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
 	haveWAL := wal.Exist(cfg.WALDir())
 	ss := snap.New(cfg.SnapDir())
 
-	pt, err := transport.NewTransport(cfg.PeerTLSInfo, cfg.peerDialTimeout())
+	// use timeout transport to pair with remote timeout listeners
+	pt, err := transport.NewTimeoutTransport(cfg.PeerTLSInfo, cfg.peerDialTimeout(), 0, 0)
 	if err != nil {
 		return nil, err
 	}

+ 2 - 1
rafthttp/transport.go

@@ -143,7 +143,8 @@ func (t *Transport) Start() error {
 	if err != nil {
 		return err
 	}
-	t.pipelineRt, err = transport.NewTransport(t.TLSInfo, t.DialTimeout)
+	// use timeout transport to pair with remote timeout listeners
+	t.pipelineRt, err = transport.NewTimeoutTransport(t.TLSInfo, t.DialTimeout, 0, 0)
 	if err != nil {
 		return err
 	}