Skip to content

Using .ping() to check connectivity? #735

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

Closed
fosini opened this issue Jan 10, 2018 · 1 comment
Closed

Using .ping() to check connectivity? #735

fosini opened this issue Jan 10, 2018 · 1 comment

Comments

@fosini
Copy link

fosini commented Jan 10, 2018

https://stackoverflow.com/questions/41618428/golang-ping-succeed-the-second-time-even-if-database-is-down

Ping, after the first connection, doesn't actually ping the database. It's odd, and wrong, but that's the way it works (until Go 1.8). If there's an existing connection in the connection pool that hasn't timed out, Ping will simply remove it from the pool and return it to you, without actually bothering to check if the database is still there.

Kardianos (who wrote the above linked document, as well as Govendor) fixed this in 1.8, provided the database driver supports it. Until then, however, Ping isn't reliable for determining if the database is still there.

Hello.
Is it ok now to use ping now to check if my connection is still there?

Thanks a lot

@methane
Copy link
Member

methane commented Jan 11, 2018

Yes, see #572.

@methane methane closed this as completed Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants