Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#40284
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
xuyifangreeneyes authored and ti-chi-bot committed Jan 4, 2023
1 parent 5ccc10b commit 46724b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,17 @@ func killConn(conn *clientConn) {
}
}

// KillSysProcesses kill sys processes such as auto analyze.
func (s *Server) KillSysProcesses() {
if s.dom == nil {
return
}
sysProcTracker := s.dom.SysProcTracker()
for connID := range sysProcTracker.GetSysProcessList() {
sysProcTracker.KillSysProcess(connID)
}
}

// KillAllConnections kills all connections when server is not gracefully shutdown.
func (s *Server) KillAllConnections() {
logutil.BgLogger().Info("[server] kill all connections.")
Expand All @@ -714,6 +725,11 @@ func (s *Server) KillAllConnections() {
}
killConn(conn)
}
<<<<<<< HEAD
=======

s.KillSysProcesses()
>>>>>>> 62a713394f (server, tidb-server: kill auto analyze when gracefully shutting down (#40284))
}

var gracefulCloseConnectionsTimeout = 15 * time.Second
Expand Down
3 changes: 3 additions & 0 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,9 @@ func cleanup(svr *server.Server, storage kv.Storage, dom *domain.Domain, gracefu
if graceful {
done := make(chan struct{})
svr.GracefulDown(context.Background(), done)
// Kill sys processes such as auto analyze. Otherwise, tidb-server cannot exit until auto analyze is finished.
// See https://github.com/pingcap/tidb/issues/40038 for details.
svr.KillSysProcesses()
} else {
svr.TryGracefulDown()
}
Expand Down

0 comments on commit 46724b0

Please sign in to comment.