From 1dab736948adbe81e2e60c4ca977b14fd6b1102b Mon Sep 17 00:00:00 2001 From: luancheng Date: Mon, 30 Mar 2020 22:14:42 +0800 Subject: [PATCH] address comment --- pkg/task/restore.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/pkg/task/restore.go b/pkg/task/restore.go index 1e753ee9a..90cf9fde5 100644 --- a/pkg/task/restore.go +++ b/pkg/task/restore.go @@ -48,9 +48,8 @@ const ( type RestoreConfig struct { Config - Online bool `json:"online" toml:"online"` - NoSchema bool `json:"no-schema" toml:"no-schema"` - MaxIndexLength int `json:"max-index-length" toml:"max-index-length"` + Online bool `json:"online" toml:"online"` + NoSchema bool `json:"no-schema" toml:"no-schema"` } // DefineRestoreFlags defines common flags for the restore command. @@ -58,11 +57,9 @@ func DefineRestoreFlags(flags *pflag.FlagSet) { // TODO remove experimental tag if it's stable flags.Bool(flagOnline, false, "(experimental) Whether online when restore") flags.Bool(flagNoSchema, false, "skip creating schemas and tables, reuse existing empty ones") - flags.Int(flagMaxIndexLength, 3072, "need keep this as same as tidb max-index-length") // Do not expose this flag _ = flags.MarkHidden(flagNoSchema) - _ = flags.MarkHidden(flagMaxIndexLength) } // ParseFromFlags parses the restore-related flags from the flag set. @@ -76,10 +73,6 @@ func (cfg *RestoreConfig) ParseFromFlags(flags *pflag.FlagSet) error { if err != nil { return errors.Trace(err) } - cfg.MaxIndexLength, err = flags.GetInt(flagMaxIndexLength) - if err != nil { - return errors.Trace(err) - } err = cfg.Config.ParseFromFlags(flags) if err != nil { return errors.Trace(err) @@ -158,9 +151,11 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf } // execute DDL first - // set max index length before execute DDLs and create tables + // set max-index-length before execute DDLs and create tables + // we set this value to max(3072*4), otherwise we might not restore table + // when upstream and downstream both set this value greater than default(3072) conf := config.GetGlobalConfig() - conf.MaxIndexLength = cfg.MaxIndexLength + conf.MaxIndexLength = config.DefMaxOfMaxIndexLength config.StoreGlobalConfig(conf) err = client.ExecDDLs(ddlJobs)