-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Online DDL: resume vreplication after cut-over/RENAME failure #18428
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
Changes from 1 commit
474fb29
67de091
b180f6f
b337478
bffd76f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -621,10 +621,20 @@ func (e *Executor) terminateVReplMigration(ctx context.Context, uuid string) err | |
| if _, err := e.vreplicationExec(ctx, tablet.Tablet, query); err != nil { | ||
| log.Errorf("FAIL vreplicationExec: uuid=%s, query=%v, error=%v", uuid, query, err) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| if err := e.deleteVReplicationEntry(ctx, uuid); err != nil { | ||
| func (e *Executor) startVreplication(ctx context.Context, tablet *topodatapb.Tablet, workflow string) (err error) { | ||
| query, err := sqlparser.ParseAndBind(sqlStartVReplStream, | ||
| sqltypes.StringBindVariable(e.dbName), | ||
| sqltypes.StringBindVariable(workflow), | ||
| ) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if _, err := e.vreplicationExec(ctx, tablet, query); err != nil { | ||
| return vterrors.Wrapf(err, "FAIL vreplicationExec: uuid=%s, query=%v", workflow, query) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
|
|
@@ -1071,6 +1081,16 @@ func (e *Executor) cutOverVReplMigration(ctx context.Context, s *VReplStream, sh | |
| } | ||
| go log.Infof("cutOverVReplMigration %v: stopped vreplication", s.workflow) | ||
|
|
||
| defer func() { | ||
| if !renameWasSuccessful { | ||
| // Restarting vreplication | ||
| if err := e.startVreplication(ctx, tablet.Tablet, s.workflow); err != nil { | ||
| log.Errorf("cutOverVReplMigration %v: failed restarting vreplication after cutover failure: %v", s.workflow, err) | ||
| } | ||
| go log.Infof("cutOverVReplMigration %v: started vreplication after cutover failure", s.workflow) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why to start a goroutine for calling in log function?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because in this critical section I don't want to block on writing a log line, as silly as it may be.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shlomi-noach Is it then essential to log at all? Starting a goroutine also has some cost 😄.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dbussink , yeah, I'd like this entry to appear in the logs. If it appears, it means vreplication has definitely started, which is an important info
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will not be the only |
||
| } | ||
| }() | ||
|
|
||
| // rename tables atomically (remember, writes on source tables are stopped) | ||
| { | ||
| if isVreplicationTestSuite { | ||
|
|
@@ -3137,6 +3157,7 @@ func (e *Executor) reviewRunningMigrations(ctx context.Context) (countRunnning i | |
| cancellable = append(cancellable, newCancellableMigration(uuid, s.message)) | ||
| } | ||
| if !s.isRunning() { | ||
| log.Infof("migration %s in 'running' state but vreplication state is '%s'", uuid, s.state.String()) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just some added visibility. |
||
| return nil | ||
| } | ||
| // This VRepl migration may have started from outside this tablet, so | ||
|
|
@@ -4128,7 +4149,7 @@ func (e *Executor) ForceCutOverPendingMigrations(ctx context.Context) (result *s | |
| if err != nil { | ||
| return result, err | ||
| } | ||
| log.Infof("ForceCutOverPendingMigrations: iterating %v migrations %s", len(uuids)) | ||
| log.Infof("ForceCutOverPendingMigrations: iterating %v migrations", len(uuids)) | ||
|
|
||
| result = &sqltypes.Result{} | ||
| for _, uuid := range uuids { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.