Skip to content

driver can drop server-side query timeout error #1075

@acharis

Description

@acharis

If a query takes too long in the sense of exceeding max_execution_time then the driver should report an error. I can reproduce lacking this error.

package main

import (
 "database/sql"
 "fmt"
 "time"
 _ "github.com/go-sql-driver/mysql"
)

func main() {
 db, err := sql.Open("mysql", "username:password@tcp(1.2.3.4:3306)/dbname")
 if err != nil {
    fmt.Println(err)
    return
 }

  defer db.Close()
  start := time.Now()
  rows, err := db.Query("SELECT count(*) FROM foo")
  if err != nil {
   fmt.Println(err.Error())
   return
  }

  t := time.Now()
  elapsed := t.Sub(start)
  fmt.Println(elapsed)

  var count int64
  for rows.Next() {
    err := rows.Scan(&count)
    if err != nil {
      fmt.Println(err)
      return
    }
    fmt.Printf("count: %d\n", count)
  }
}

I expect an error after db.Query

Built against go-sql-driver/mysql commit 681ffa8

go version
go version go1.12.14 linux/amd64

mysql version: 5.7.25-28-log Percona Server (GPL), Release 28, Revision c335905

uname -a
Linux pause-pod 5.4.20-hs768.el6.x86_64 #1 SMP Tue Mar 17 16:38:55 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

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