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 was introducing latency. Can you make 
> some benchmarks with a real driver, one with the normal code and one with 
> the sync check commented out?


I found this problem when implement a sql driver for our private mysql 
proxy. Before disconnect from the proxy, the client need to send a message 
and wait for server reply.
I do this in driver.Close() method. That may block an online query request 
if the close operation in the synchronous check.
It happended frequently if  SetConnMaxLifetime() to a short duration, for 
example, 3 seconds. 

I also notice that in the mysql dirver 
(https://github.com/go-sql-driver/mysql), it will send packet to mysql 
server during driver.Close().  
https://github.com/go-sql-driver/mysql/blob/master/connection.go#L100
 97 func (mc *mysqlConn) Close() (err error) {
  98     // Makes Close idempotent
  99     if !mc.closed.IsSet() {
* 100         err = mc.writeCommandPacket(comQuit)                         
                                                                            
               *
 101     }
 102 
 103     mc.cleanup()
 104 
 105     return
 106 }


I will do a benchmark for the mysql driver later. 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to