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

TiDB will not wait for auto-commit statements during graceful shutdown #55464

Closed
YangKeao opened this issue Aug 16, 2024 · 1 comment · Fixed by #55494
Closed

TiDB will not wait for auto-commit statements during graceful shutdown #55464

YangKeao opened this issue Aug 16, 2024 · 1 comment · Fixed by #55494
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@YangKeao
Copy link
Member

Bug Report

In the following logic, conn.getCtx().GetSessionVars().InTxn() is only true for explictly transactions. Therefore, the DrainClients will not wait for auto-commit statements, and results in leaking locks.

// DrainClients drain all connections in drainWait.
// After drainWait duration, we kill all connections still not quit explicitly and wait for cancelWait.
func (s *Server) DrainClients(drainWait time.Duration, cancelWait time.Duration) {
...
	go func() {
		defer close(allDone)
		for _, conn := range conns {
			if !conn.getCtx().GetSessionVars().InTxn() {
				continue
			}
			select {
			case <-conn.quit:
			case <-quitWaitingForConns:
				return
			}
		}
	}()
...
}

It'd be better to also wait for all auto-commit statements to finish 🤔 .

@YangKeao YangKeao added the type/bug The issue is confirmed as a bug. label Aug 16, 2024
@YangKeao
Copy link
Member Author

It's introduced by #44953

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants