Skip to content

Commit

Permalink
fix read tcp i/o timeout in copy-shard #39
Browse files Browse the repository at this point in the history
  • Loading branch information
chengshiwen committed Sep 3, 2024
1 parent 61feb3d commit 1805395
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions coordinator/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1805395

Please sign in to comment.