diff --git a/server/conn.go b/server/conn.go index e0dcae450a754..39aae85ef483c 100644 --- a/server/conn.go +++ b/server/conn.go @@ -1069,12 +1069,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 c96d64a3b982b..3da7b823d025b 100644 --- a/server/server.go +++ b/server/server.go @@ -633,9 +633,6 @@ func (s *Server) getUserProcessList() map[uint64]*util.ProcessInfo { defer s.rwlock.RUnlock() rs := make(map[uint64]*util.ProcessInfo) for _, client := range s.clients { - if atomic.LoadInt32(&client.status) == connStatusWaitShutdown { - continue - } if pi := client.ctx.ShowProcess(); pi != nil { rs[pi.ID] = pi } @@ -709,6 +706,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.