Re: [go-nuts] Re: database/sql: Latency when calling DB.QueryContext()

2023-11-03 Thread Robert Engels
The internet. The gift that keeps on giving. > On Nov 3, 2023, at 7:54 AM, Al Corona wrote: > > Off topic question. But does anyone know how I can gain admin access on my > work computer? > >> On Thursday, June 29, 2017 at 12:01:16 AM UTC-7 Kai Zhang wrote: >> Go version 1.8.3 >> >> In DB.

[go-nuts] Re: database/sql: Latency when calling DB.QueryContext()

2023-11-03 Thread Al Corona
Off topic question. But does anyone know how I can gain admin access on my work computer? On Thursday, June 29, 2017 at 12:01:16 AM UTC-7 Kai Zhang wrote: > Go version 1.8.3 > > In DB.QueryContext(), Go will close long live connection which exceeded > the duration setted by DB.SetConnMaxLifet

[go-nuts] Re: database/sql: Latency when calling DB.QueryContext()

2017-06-30 Thread Kai Zhang
In my private sql driver implementation, I need to do some clean up during conn.Close(). That clean up may block the DB.Query() for a second. That lead to the latency. Now I fix this problem by making conn.Close() do clean up asynchronously, so the conn.Close() can return fast. Doing clean up s

[go-nuts] Re: database/sql: Latency when calling DB.QueryContext()

2017-06-30 Thread Kai Zhang
Benchmark is not fair to this problem, it is the mean latency value. This time I wrote a simple test, and just log the time elapsed. Here is the code: package main import ( "database/sql" "fmt" "os" "time" _ "github.com/go-sql-driver/mysql" ) var db *sql.DB func RunNoMaxLifetime() { db.SetC

[go-nuts] Re: database/sql: Latency when calling DB.QueryContext()

2017-06-29 Thread Kai Zhang
In the mysqlConn.Close() method of mysql driver, it just send a quit command, not wait for the server reply. So the latency is neglectable. But in my sql driver, I did some clean up, that make the conn.Close() block. Now I fix this problem by doing close asynchronously, and keep conn.Close() r

[go-nuts] Re: database/sql: Latency when calling DB.QueryContext()

2017-06-29 Thread Kai Zhang
here is the benchmark result for mysql driver: k@k-ThinkPad-X270:sql$ go test -v -bench . --benchtime 60s -parallel 10 BenchmarkNoMaxLifetime-4 1000 13480 ns/op BenchmarkMaxLifetime1S-4 1000 14356 ns/op PASS ok _/home/k/Desktop/work/test/sql 303.967s The benchmark code is he

[go-nuts] Re: database/sql: Latency when calling DB.QueryContext()

2017-06-29 Thread Kai Zhang
Thanks for the reply. > I don't think this has anything to do with the Context method variants or > Context related code. > Yes, the DB.Query() method also has this problem. This is just two different checks. One when the connection is returned, one > periodically. You seemed to say this wa

[go-nuts] Re: database/sql: Latency when calling DB.QueryContext()

2017-06-29 Thread Daniel Theophanes
I don't think this has anything to do with the Context method variants or Context related code. This is just two different checks. One when the connection is returned, one periodically. You seemed to say this was introducing latency. Can you make some benchmarks with a real driver, one with the