Skip to content

sql-server: kill query spam with parameterized statements #4601

@nairb774

Description

@nairb774

For every parameterized query that is issued, the sql-server seems to generate a INFO [no conn] kill query: pid 1089 {} style line on connection close. If a connection is used to issue large volumes of queries, then the log spam can be quite significant.

The following code can be run against an empty dolt sql-server:

package main

import (
        "database/sql"
        "flag"

        _ "github.com/go-sql-driver/mysql"
)

var dbURI = flag.String("db", "", "URL of MySQL DB to connect to")

func main() {
        flag.Parse()

        db, err := sql.Open("mysql", *dbURI)
        if err != nil {
                panic(err)
        }
        defer db.Close()

        // Change loop count to generate a log line per iteration:
        for i := 0; i < 5; i++ {
                var out int64
                if err := db.QueryRow("SELECT ?", 1).Scan(&out); err != nil {
                        panic(err)
                }
        }
}

Issuing a query like SELECT 1 doesn't cause log spam. I couldn't find any use of the database/sql APIs that would avoid the log spam when using parameters.

go.mod for good measure:

module repro

go 1.19

require github.com/go-sql-driver/mysql v1.6.0

And dolt version:

$ dolt version
dolt version 0.50.8
database storage format: NEW ( __DOLT__ )

It seems like some internal resource isn't being released correctly until the connection itself is closed.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood reproEasily reproducible bugssql serverIssues related to the built in SQL server

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions