Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
database/sql: no way to protect driver.Connector.Connect(), driver.Conn.Close(), driver.Stmt.Close() from blocking #38185
I was reading
Please let me know If I missing something.
What version of Go are you using (
Correct on all counts.
Closing a connection is unlikely to involve a network round-trip. Or rather, I don't know of any that would require that, so I'm less worried about this.
Closing a Stmt will always require a network round trip, unless the entire connection is broken. The hard thing with this is the that the sql package doesn't expose a Stmt object, just a Stmt pool object. Which makes synchronous, context bounded closing harder.
Lastly, yes, the connection opener context improves the situation, but it doesn't address all the cases. I'm not 100% sure we can fix this with the current API, but you could try / make suggestions on how to best address this.
Some of these issues are caused by the original API that will be hard to change unless we issue a v2. For somethings, simply better documentation, stating that drivers should include a sane timeout for certain calls would also be an improvement.
If you don't expect
Yeah, passing context to
Regarding the connection opener, I thought we could pass a request bounded context from the user into
@georgysavva I agree that the background connection opener makes it difficult to provide a relevant context for all situations. Can you review the above CL to see if it addresses your concerns? If you have a gerrit account, please leave feedback on the CL itself, otherwise feedback here is fine too. Thanks.
Opening a connection with Connect should still create a derived context with a timeout because some clients will not use a timeout and the connection pool may open a connection asynchronously. Likewise, if a connection close makes a network operation it should provide some type of sane timeout for the operation. Fixes golang#38185 Change-Id: I9b7ce2996c81c486170dcc84b12672a99610fa27 Reviewed-on: https://go-review.googlesource.com/c/go/+/230438 Reviewed-by: Emmanuel Odeke <firstname.lastname@example.org>