-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
driver can drop server-side query timeout error #1075
Comments
I have also reproduced this against:
|
Have you checked rows.Err()? |
checking that now, via: package main
import (
"database/sql"
"fmt"
"time"
_ "github.com/go-sql-driver/mysql"
)
func main() {
db, err := sql.Open("mysql", "vt_hsmysql_read:T}MLBFCNroXKFzR;oPZUJ2Qve@tcp(172.18.153.145:3306)/VitessTest")
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)
err = rows.Err()
if err != nil {
fmt.Println(err)
return
}
var count int64
for rows.Next() {
err := rows.Scan(&count)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("count: %d\n", count)
}
} i still don't see any error. |
i've also now reproduced this in v1.2.0, v1.3.0, v1.4.0 as well as the original v1.5.0 |
is that only populated upon call to Next ? |
ah yeah, so we've got to call next then check for error |
x-ref: github/gh-ost#822 |
i'm closing this, b/c it seems like the user (here the gh-ost application) isn't checking for the error in the way that go-sql-driver expects, but i'll note that it's surprising to me that we'd need to call Next to be able to see this error. that feels unergonomic to me. i'd expect the error in the |
This is low level library. It is not designed for ergonomic. You can use some wrapper library if you want "ergonomic" design. |
Closes github#822. In go-sql-driver/mysql#1075, @acharis notes that the way the go-sql driver is written, query timeout errors don't get set in `rows.Err()` until _after_ a call to `rows.Next()` is made. Because this kind of error means there will be no rows in the result set, the `for rows.Next()` will never enter the for loop, so we must check the value of `rows.Err()` after the loop, and surface the error up appropriately.
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.I expect an error after
db.Query
Built against go-sql-driver/mysql commit 681ffa8
mysql version:
5.7.25-28-log Percona Server (GPL), Release 28, Revision c335905
The text was updated successfully, but these errors were encountered: