Skip to content

Use native DB.Ping() instead of self-written implementation #210

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

Merged
merged 1 commit into from
Jun 28, 2018

Conversation

arvenil
Copy link
Contributor

@arvenil arvenil commented Jun 16, 2017

I know it's trivial :P But I'm curious why not use native DB.Ping() instead of in-house implementation? It should also avoid generating unnecessary SELECT 1 statements.

@SuperQ
Copy link
Member

SuperQ commented Jun 16, 2017

Totally reasonable to me, the SELECT 1 pattern came from some app implementations with bad SQL drivers. This is better.

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SuperQ
Copy link
Member

SuperQ commented Jun 16, 2017

One note, we need to update the go mysql driver vendoring, as the Ping() function is not implemented in the current version. I will send out a general vendoring update PR.

@SuperQ
Copy link
Member

SuperQ commented Jun 16, 2017

It looks like this was only implemented recently0 and is not in an official release of the driver just yet. I think I want to hold off on this and wait till the upstream driver declares it in a stable release.

@arvenil
Copy link
Contributor Author

arvenil commented Jun 16, 2017

Interesting. Just to clarify.

https://golang.org/pkg/database/sql/#DB.Ping is there since like forever™️
I just read DB.Ping is making a new connection to DB (which often is enough) but with implementation of Pinger interface it will now also send ping packet to db (definitely better and more close to SELECT 1 query test).

👍

@SuperQ
Copy link
Member

SuperQ commented Jul 5, 2017

Looks like this needs a rebase.

@SuperQ
Copy link
Member

SuperQ commented Jul 6, 2017

FYI, I'm not ignoring this, but there is still no upstream release of the driver that contains the new db.Ping() version.

@SuperQ
Copy link
Member

SuperQ commented Jun 26, 2018

We've merged 1.4.0, please rebase. 😄

@arvenil
Copy link
Contributor Author

arvenil commented Jun 28, 2018

Done.

@SuperQ SuperQ merged commit 6b4e3df into prometheus:master Jun 28, 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

Successfully merging this pull request may close these issues.

2 participants