Skip to content

Connect is leaking connections when context is quickly canceled #1023

Closed
@mherr-google

Description

@mherr-google

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions