-
Notifications
You must be signed in to change notification settings - Fork 18k
database/sql: db.PingContext takes longer to time out on certain database host IPs than on others (postgresql and mysql) #27476
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
Comments
541 is larger then 255 and invalid. Please ensure the drivers use the provided context when dialing. Maybe inspect the MySQL driver dial code or file a bug there. |
It seems that in https://github.com/golang/go/blob/master/src/database/sql/sql.go#L1177:
It won't respect ctx if make a connection request at last. |
Ah yes, This isn't an issue of not supporting PingContext, these drivers need to support the new Connector interface because this is a dial timeout. |
@andybons There isn't actually a fix here for Go. I wasn't sure if I should leave this issue open as a tracking issue for drivers who need to implement the Connector interface. I haven't had time to look thorugh the various drivers yet. |
@kardianos I see. Feel free to keep open and use it as a tracking bug for other drivers if you want, though I don’t know what qualifies as “fixed” in this case. Can you update the title to properly represent the issue? |
The mysql driver has two pull requests to support the Connector. Nothing merged as of yet. The postgresql driver supports the connector interface, but discards the context passed in. https://github.com/lib/pq/blob/90697d60dd844d5ef6ff15135d0203f65d2f53b8/connector.go#L23 I'm closing this issue as there is nothing to be done. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go1.10.1 linux/amd64
Does this issue reproduce with the latest release?
Yes, at least on go1.10.4 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
What did you do?
Attempted to use context.WithTimeout to limit the amount of time a PingContext() command takes to try and access a database server.
What did you expect to see?
A timeout of 2- seconds for 172.1.2.3
A timeout of 2- seconds for 541.1.2.3
What did you see instead?
A timeout of 2+ minutes for 172.1.2.3
(An immediate timeout for 541.1.2.3, which is ok)
The text was updated successfully, but these errors were encountered: