-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[vitessdriver|vtadmin] Support Ping in vitessdriver, use in vtadmin to healthcheck connections during Dial #7709
Conversation
Ref: https://golang.org/pkg/database/sql/driver/#Pinger Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
@@ -132,13 +136,27 @@ func (vtgate *VTGateProxy) Dial(ctx context.Context, target string, opts ...grpc | |||
vtgate.annotateSpan(span) | |||
|
|||
if vtgate.conn != nil { | |||
span.Annotate("is_noop", true) | |||
|
|||
// (TODO:@amason): consider a quick Ping() check in this case, and get a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good suggestion, turns out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Looks like the onlineddl_devert test is having trouble downloading a dependency from mongodb:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
This PR fixes a longstanding issue in vtadmin, where if vtadmin had
Dial
-ed a cluster, obtained a connection to a vtgate, and that vtgate was torn down, that cluster would become unusable without restarting vtadmin, and we would see the following, forever:To fix this, I've introduced the following:
database/sq/driver.Pinger
interface invitessdriver
, which just issues aselect 1
query.Ping
duringVTGateProxy.Dial
in the case where the proxy has a non-nil connection. We set a configurable timeout here, to avoid blocking forever, and if the call fails we attempt to close the connection and then fall through to the "discover new vtgate and dial it" phase of theDial
method. If the ping check succeeds, we know we can just keep using that connection.Related Issue(s)
Checklist
Deployment Notes
Impacted Areas in Vitess
Components that this PR will affect: