Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upCheck for bad connections #1256
Comments
This comment has been minimized.
|
You can easily test this with |
sgrif
closed this
Oct 11, 2017
This comment has been minimized.
|
That requires a network round-trip to complete. For the connection pooling use, that basically means every query now takes twice as long. Also, that still doesn't let you distinguish between network errors and other random DB server errors. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jethrogb commentedOct 11, 2017
There is currently no portable way to tell whether a database connection is still usable. Yes, queries might return an
Error, but you can't easily tell from that whether it was just something with the query or database, or the connection. Also, when using connection pooling, you want to know when a connection is returned to the pool whether to retire it or not. This would require just querying the connection without knowing anything about its history.I suggest adding an
fn is_usabletotrait Connectionor similar. In Postgres, this can be implemented withPQstatus. MySQL hopefully has something similar.