Skip to content

Memory loitering in driver for reused connections and protocol path that doesn't reset affectedRows and insertIDs accumulators #1304

Closed
@aforrest-google

Description

@aforrest-google

Issue description

After the introduction of #1263 which adds support for multiple rows affected and insert IDs being returned for multi-statement requests, there are some conditions that lead to a memory loitering issue (both must be true):

  1. If the connection is reused
  2. If the protocol path involved results in an OK Packet (e.g. a resultSetHeaderPacket)

Notably, the Query path in the driver implementation is affected by this second condition. Any extremely long running process that continually reuses a connection and uses the Query path (as opposed to the Exec path) will experience this issue.

Example code

  for {
    if err := conn.Ping(); err != nil {
      return err
    }
    time.Sleep(time.Second)
  }

Error log

Not applicable.

Configuration

Driver version (or git SHA): 1.6

Go version: 1.17

Server version: MySQL 5.7

Server OS: N/A

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