diff --git a/server/conn.go b/server/conn.go index b671ec1502fc7..65cc2581d9c66 100644 --- a/server/conn.go +++ b/server/conn.go @@ -833,12 +833,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 1b1929a9854d8..2140eeecb048e 100644 --- a/server/server.go +++ b/server/server.go @@ -603,6 +603,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.