Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: fix show problem for kill tidb connection (#24031) #29212

Merged
merged 11 commits into from
Nov 12, 2021
2 changes: 2 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,8 @@ func (s *Server) getTLSConfig() *tls.Config {
func killConn(conn *clientConn) {
sessVars := conn.ctx.GetSessionVars()
atomic.StoreUint32(&sessVars.Killed, 1)
// 'Kill' status can be showed in Command/Info field when show processlist
conn.ctx.SetProcessInfo("this session is being killed", time.Now(), mysql.ComProcessKill, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, for MySQL compatibility the Info column is not overwritten. This helps you see what is being actively killed. The State should also say "Killed" instead of autocommit.

For #24031, there are really two issues:

  1. Update the status for connections which have been "killed" so that it is more accurate.
  2. Change the wait_timeout to be a loop, so the connection which is being killed can cleanup faster.

This fixes issue (1), but we should also fix (2) to consider #24031 resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx for your review, and do we need design doc for fix (2)?

conn.mu.RLock()
cancelFunc := conn.mu.cancelFunc
conn.mu.RUnlock()
Expand Down