-
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
VReplication: recover from closed connection #17249
VReplication: recover from closed connection #17249
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
…eopen it Signed-off-by: Shlomi Noach <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17249 +/- ##
=======================================
Coverage 67.39% 67.39%
=======================================
Files 1570 1570
Lines 252917 252930 +13
=======================================
+ Hits 170446 170470 +24
+ Misses 82471 82460 -11 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
if vr.dbClient.IsClosed() { | ||
// Connection was possible terminated by the server. We should renew it. | ||
if cerr := vr.dbClient.Connect(); cerr != nil { | ||
return vterrors.Wrapf(err, "failed to reconnect to the database: %v", cerr) |
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.
Shouldn't we check if the context was not canceled before trying to reconnect?
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.
Good observation -- but not in this case. We absolutely must try and issue vr.setMessage(err.Error())
so as to persist the error and the state of the stream.
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.
Left a comment, otherwise LGTM
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]> Signed-off-by: Renan Rangel <[email protected]>
Description
When
vreplicator
fails, check if its connection is closed, and if so, reopen it. This addresses #17248 where the binlog connection auto closes itself in response to a bad commit (MySQL error1180
), but will just as well apply to any situation where the connection closes. It's imperative to open the connection so as to be able to set state/message.Related Issue(s)
Fixes #17248
Checklist
Deployment Notes