TiDB graceful shutdown should kill all running statements before closing the session
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
TiDB kills connection after cleans up the session:
```go
// KillAllConnections implements the SessionManager interface.
// KillAllConnections kills all connections.
func (s *Server) KillAllConnections() {
logutil.BgLogger().Info("kill all connections.", zap.String("category", "server"))
s.rwlock.RLock()
defer s.rwlock.RUnlock()
for _, conn := range s.clients {
conn.setStatus(connStatusShutdown)
if err := conn.closeWithoutLock(); err != nil {
terror.Log(err)
}
killQuery(conn, false)
}
s.KillSysProcesses()
}
```
If the `conn` is still running after the session is reset, it can cause panic or any unexpected behavior. However, as the TiDB is shutting down, the only difference is returning a `panic` error or a `timeout`/`killed` error, so it's not a big problem.
Contributor guide
Assessment
This issue has not been assessed yet.