From 18053955236071faf08420531a9adec2ed70fdf4 Mon Sep 17 00:00:00 2001 From: chengshiwen Date: Tue, 3 Sep 2024 23:56:56 +0800 Subject: [PATCH] fix read tcp i/o timeout in copy-shard #39 --- coordinator/service.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/coordinator/service.go b/coordinator/service.go index 0e18828..5884fa6 100644 --- a/coordinator/service.go +++ b/coordinator/service.go @@ -120,9 +120,6 @@ const ( removeHintedHandoffResponseMessage ) -// BackupTimeout is the time before a connection times out when performing a backup. -const BackupTimeout = 30 * time.Second - // ShardIDsKey is the shardIDs context key when handling read request. const ShardIDsKey ContextKey = iota + 1 @@ -1190,11 +1187,10 @@ func (s *Service) processCopyShardRequest(conn net.Conn) { // backupRemoteShard connects to a coordinator service on a remote host and streams a shard. func (s *Service) backupRemoteShard(host string, shardID uint64, since time.Time) (io.ReadCloser, error) { tlsConfig := s.config.TLSClientConfig() - conn, err := tcp.DialTLS("tcp", host, tlsConfig) + conn, err := tcp.DialTLSTimeout("tcp", host, tlsConfig, time.Duration(s.config.DialTimeout)) if err != nil { return nil, err } - conn.SetDeadline(time.Now().Add(BackupTimeout)) if err := func() error { // Write the coordinator multiplexing header byte