diff --git a/server/conn.go b/server/conn.go index 8c4a4be1d95fd..80730acf3590d 100644 --- a/server/conn.go +++ b/server/conn.go @@ -824,12 +824,16 @@ func (cc *clientConn) Run(ctx context.Context) { if err != nil { if terror.ErrorNotEqual(err, io.EOF) { if netErr, isNetErr := errors.Cause(err).(net.Error); isNetErr && netErr.Timeout() { - idleTime := time.Since(start) - logutil.Logger(ctx).Info("read packet timeout, close this connection", - zap.Duration("idle", idleTime), - zap.Uint64("waitTimeout", waitTimeout), - zap.Error(err), - ) + if atomic.LoadInt32(&cc.status) == connStatusWaitShutdown { + logutil.Logger(ctx).Info("read packet timeout because of killed connection") + } else { + idleTime := time.Since(start) + logutil.Logger(ctx).Info("read packet timeout, close this connection", + zap.Duration("idle", idleTime), + zap.Uint64("waitTimeout", waitTimeout), + zap.Error(err), + ) + } } else { errStack := errors.ErrorStack(err) if !strings.Contains(errStack, "use of closed network connection") { diff --git a/server/server.go b/server/server.go index d88c6d26237fd..38f6c82f1ef76 100644 --- a/server/server.go +++ b/server/server.go @@ -578,6 +578,11 @@ func killConn(conn *clientConn) { if cancelFunc != nil { cancelFunc() } + if conn.bufReadConn != nil { + if err := conn.bufReadConn.SetReadDeadline(time.Now()); err != nil { + logutil.BgLogger().Warn("error setting read deadline for kill.", zap.Error(err)) + } + } } // KillAllConnections kills all connections when server is not gracefully shutdown.