Skip to content

Context cancelling cause close connection without sending COMM_QUIT for authenticated connection #1648

@minhquang4334

Description

@minhquang4334

Issue description

startWatcher() watches the context provided by the Go client. When context cancellation occurs, this method only cleanup() the connection without sending COMM_QUIT, regardless of whether the connection has already been authenticated or not.

Without COMM_QUIT, MySQL Server will abort authenticated clients, and increase Aborted_clients metric.

Related code

  • Current handling when context cancel:

  • But cleanup() is only called before auth or on auth failure

    • mysql/connection.go

      Lines 134 to 138 in c9f41c0

      // Closes the network connection and unsets internal variables. Do not call this
      // function after successfully authentication, call Close instead. This function
      // is called before auth or on auth failure because MySQL will have already
      // closed the network connection.
      func (mc *mysqlConn) cleanup() {
  • Close() should be called if the connection has been authenticated successfully with sending COMM_QUIT to MySQL server

Error log

If you have an error log, please paste it here.

Configuration

Driver version (or git SHA): 1.8.1

Go version: run go version in your console

Server version: E.g. MySQL 5.6, MariaDB 10.0.20

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions