diff --git a/go/vt/vtctl/vtctl.go b/go/vt/vtctl/vtctl.go index 3d39dffb5e9..37ad61922ce 100644 --- a/go/vt/vtctl/vtctl.go +++ b/go/vt/vtctl/vtctl.go @@ -402,8 +402,8 @@ var commands = []commandGroup{ "[-exclude_tables=''] [-include-views] [-skip-no-master] ", "Validates that the master schema from shard 0 matches the schema on all of the other tablets in the keyspace."}, {"ApplySchema", commandApplySchema, - "[-allow_long_unavailability] [-wait_replicas_timeout=10s] [-ddl_strategy=] [-skip_preflight] {-sql= || -sql-file=} ", - "Applies the schema change to the specified keyspace on every master, running in parallel on all shards. The changes are then propagated to replicas via replication. If -allow_long_unavailability is set, schema changes affecting a large number of rows (and possibly incurring a longer period of unavailability) will not be rejected. ddl_strategy is used to intruct migrations via gh-ost or pt-osc with optional parameters. If -skip_preflight, SQL goes directly to shards without going through sanity checks"}, + "[-allow_long_unavailability] [-wait_replicas_timeout=10s] [-ddl_strategy=] [-request_context=] [-skip_preflight] {-sql= || -sql-file=} ", + "Applies the schema change to the specified keyspace on every master, running in parallel on all shards. The changes are then propagated to replicas via replication. If -allow_long_unavailability is set, schema changes affecting a large number of rows (and possibly incurring a longer period of unavailability) will not be rejected. -ddl_strategy is used to intruct migrations via vreplication, gh-ost or pt-osc with optional parameters. -request_context allows the user to specify a custom request context for online DDL migrations. If -skip_preflight, SQL goes directly to shards without going through sanity checks"}, {"CopySchemaShard", commandCopySchemaShard, "[-tables=,,...] [-exclude_tables=,,...] [-include-views] [-skip-verify] [-wait_replicas_timeout=10s] { || } ", "Copies the schema from a source shard's master (or a specific tablet) to a destination shard. The schema is applied directly on the master of the destination shard, and it is propagated to the replicas through binlogs."}, @@ -2810,6 +2810,7 @@ func commandApplySchema(ctx context.Context, wr *wrangler.Wrangler, subFlags *fl sql := subFlags.String("sql", "", "A list of semicolon-delimited SQL commands") sqlFile := subFlags.String("sql-file", "", "Identifies the file that contains the SQL commands") ddlStrategy := subFlags.String("ddl_strategy", string(schema.DDLStrategyDirect), "Online DDL strategy, compatible with @@ddl_strategy session variable (examples: 'gh-ost', 'pt-osc', 'gh-ost --max-load=Threads_running=100'") + requestContext := subFlags.String("request_context", "", "For Only DDL, optionally supply a custom unique string used as context for the migration(s) in this command. By default a unique context is auto-generated by Vitess") waitReplicasTimeout := subFlags.Duration("wait_replicas_timeout", wrangler.DefaultWaitReplicasTimeout, "The amount of time to wait for replicas to receive the schema change via replication.") skipPreflight := subFlags.Bool("skip_preflight", false, "Skip pre-apply schema checks, and dircetly forward schema change query to shards") if err := subFlags.Parse(args); err != nil { @@ -2828,8 +2829,10 @@ func commandApplySchema(ctx context.Context, wr *wrangler.Wrangler, subFlags *fl if err != nil { return err } - requestContext := fmt.Sprintf("vtctl:%s", executionUUID) - executor := schemamanager.NewTabletExecutor(requestContext, wr, *waitReplicasTimeout) + if *requestContext == "" { + *requestContext = fmt.Sprintf("vtctl:%s", executionUUID) + } + executor := schemamanager.NewTabletExecutor(*requestContext, wr, *waitReplicasTimeout) if *allowLongUnavailability { executor.AllowBigSchemaChange() }