Skip to content

Commit

Permalink
support 'ALTER VITESS_MIGRATION FORCE_CUTOVER ALL'
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <[email protected]>
  • Loading branch information
shlomi-noach committed Nov 19, 2023
1 parent 0589d4a commit 804b684
Show file tree
Hide file tree
Showing 9 changed files with 6,106 additions and 5,935 deletions.
12 changes: 5 additions & 7 deletions go/cmd/vtctldclient/command/onlineddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ var (
RunE: commandOnlineDDLUnthrottle,
}
OnlineDDLForceCutOver = &cobra.Command{
Use: "force_cutover <keyspace> <uuid>",
Short: "Mark a given schema migration for corced cut-over.",
Use: "force_cutover <keyspace> <uuid|all>",
Short: "Mark a given schema migration, or all pending migration, for corced cut-over.",
Example: "OnlineDDL force_cutover test_keyspace 82fa54ac_e83e_11ea_96b7_f875a4d24e90",
DisableFlagsInUseLine: true,
Args: cobra.ExactArgs(2),
Expand Down Expand Up @@ -193,12 +193,10 @@ func commandOnlineDDLCleanup(cmd *cobra.Command, args []string) error {
}

func commandOnlineDDLForceCutOver(cmd *cobra.Command, args []string) error {
keyspace := cmd.Flags().Arg(0)
uuid := cmd.Flags().Arg(1)
if !schema.IsOnlineDDLUUID(uuid) {
return fmt.Errorf("%s is not a valid UUID", uuid)
keyspace, uuid, err := analyzeOnlineDDLCommandWithUuidOrAllArgument(cmd)
if err != nil {
return err
}

cli.FinishedParsing(cmd)

resp, err := client.ForceCutOverSchemaMigration(commandCtx, &vtctldatapb.ForceCutOverSchemaMigrationRequest{
Expand Down
2 changes: 2 additions & 0 deletions go/vt/sqlparser/ast_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ func (node *AlterMigration) Format(buf *TrackedBuffer) {
alterType = "unthrottle all"
case ForceCutOverMigrationType:
alterType = "force_cutover"
case ForceCutOverAllMigrationType:
alterType = "force_cutover all"
}
buf.astPrintf(node, " %#s", alterType)
if node.Expire != "" {
Expand Down
2 changes: 2 additions & 0 deletions go/vt/sqlparser/ast_format_fast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go/vt/sqlparser/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ const (
UnthrottleMigrationType
UnthrottleAllMigrationType
ForceCutOverMigrationType
ForceCutOverAllMigrationType
)

// ColumnStorage constants
Expand Down
2 changes: 2 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2421,6 +2421,8 @@ var (
input: "alter vitess_migration complete all",
}, {
input: "alter vitess_migration '9748c3b7_7fdb_11eb_ac2c_f875a4d24e90' cancel",
}, {
input: "alter vitess_migration force_cutover all",
}, {
input: "alter vitess_migration '9748c3b7_7fdb_11eb_ac2c_f875a4d24e90' force_cutover",
}, {
Expand Down
Loading

0 comments on commit 804b684

Please sign in to comment.