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

Connect is leaking connections when context is quickly canceled #1023

Closed
mherr-google opened this issue Nov 1, 2019 · 1 comment
Closed

Comments

@mherr-google
Copy link
Contributor

Issue description

mysql.Connect is leaving open connections in cases when the context is canceled very quickly. Specifically, the error branch for watchCancel() in connector.go should call mc.cleanup() but doesn't:

	// Call startWatcher for context support (From Go 1.8)
	mc.startWatcher()
	if err := mc.watchCancel(ctx); err != nil {
		return nil, err
	}
	defer mc.finish()

We've reproduced this leak internally under heavy load, and that adding a call to mc.cleanup() fixes it.

Configuration

Driver version (or git SHA): c45f530

Go version: go version go1.13 linux/amd64

Server version: MySQL 5.7

Server OS: E.g. Debian 8.1 (Jessie), Windows 10

mherr-google added a commit to mherr-google/mysql that referenced this issue Nov 1, 2019
Fix connection leak caused by rapid context cancellation (go-sql-driver#1023)
@mherr-google
Copy link
Contributor Author

I'll send a pull request fixing this shortly.

mherr-google added a commit to mherr-google/mysql that referenced this issue Nov 1, 2019
Regression test for go-sql-driver#1023.
mherr-google added a commit to mherr-google/mysql that referenced this issue Nov 1, 2019
fix go vet warning for possibly-unused cancel (go-sql-driver#1023)
@methane methane closed this as completed in 296987f Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant