Skip to content
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

vtctl ApplySchema accepts 'ALTER VITESS_MIGRATION...' statements #9303

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/releasenotes/13_0_0_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ This command indicates that a migration executed with `-postpone-completion` is
- For running `ALTER`s (`online` and `gh-ost`) which are only partly through the migration: they will cut-over automatically when they complete their work, as if `-postpone-completion` wasn't indicated
- For queued `CREATE` and `DROP` migrations: "unblock" them from being scheduled. They'll be scheduled at the scheduler's discretion. there is no guarantee that they will be scheduled to run immediately.

### vtctl ApplySchema: ALTER VITESS_MIGRATION
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
### vtctl ApplySchema: ALTER VITESS_MIGRATION
### vtctl/vtctlclient ApplySchema: ALTER VITESS_MIGRATION

Copy link
Member

Choose a reason for hiding this comment

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

Suggestion to keep this consistent with other release notes.


`vtctl ApplySchema` now supports `ALTER VITESS_MIGRATION ...` statements. Example:

```shell
$ vtctl ApplySchema -skip_preflight -sql "alter vitess_migration '9748c3b7_7fdb_11eb_ac2c_f875a4d24e90' complete" commerce
```

## Incompatible Changes

## Deprecations
22 changes: 8 additions & 14 deletions go/vt/schemamanager/tablet_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,9 @@ func (exec *TabletExecutor) executeSQL(ctx context.Context, sql string, execResu
return err
}
for _, onlineDDL := range onlineDDLs {
if exec.ddlStrategySetting.IsSkipTopo() {
exec.executeOnAllTablets(ctx, execResult, onlineDDL.SQL, true)
if len(execResult.SuccessShards) > 0 {
exec.wr.Logger().Printf("%s\n", onlineDDL.UUID)
}
} else {
exec.executeOnlineDDL(ctx, execResult, onlineDDL)
exec.executeOnAllTablets(ctx, execResult, onlineDDL.SQL, true)
if len(execResult.SuccessShards) > 0 {
exec.wr.Logger().Printf("%s\n", onlineDDL.UUID)
Copy link
Contributor Author

@shlomi-noach shlomi-noach Dec 1, 2021

Choose a reason for hiding this comment

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

The change here is to remove if exec.ddlStrategySetting.IsSkipTopo() { -- we've already hard coded that as true is previous releases.

And of course the else code cannot ever happen, so that's also removed.

}
}
return nil
Expand All @@ -267,15 +263,13 @@ func (exec *TabletExecutor) executeSQL(ctx context.Context, sql string, execResu
execResult.ExecutorErr = err.Error()
return err
}
if exec.ddlStrategySetting.IsSkipTopo() {
exec.executeOnAllTablets(ctx, execResult, onlineDDL.SQL, true)
exec.wr.Logger().Printf("%s\n", onlineDDL.UUID)
} else {
exec.executeOnlineDDL(ctx, execResult, onlineDDL)
}
exec.executeOnAllTablets(ctx, execResult, onlineDDL.SQL, true)
exec.wr.Logger().Printf("%s\n", onlineDDL.UUID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change here is to remove if exec.ddlStrategySetting.IsSkipTopo() { -- we've already hard coded that as true is previous releases.

And of course the else code cannot ever happen, so that's also removed.

return nil
case *sqlparser.AlterMigration:
exec.executeOnAllTablets(ctx, execResult, sql, true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the actual change in this PR: direct AlterMigration statements to the tablets via QueryService (that's what the last true argument indicates).

return nil
}
exec.wr.Logger().Infof("Received DDL request. strategy=%+v", schema.DDLStrategyDirect)
exec.executeOnAllTablets(ctx, execResult, sql, false)
return nil
}
Expand Down