This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
Max index length #220
Merged
Merged
Max index length #220
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import ( | |
"github.com/pingcap/log" | ||
"github.com/pingcap/parser/model" | ||
"github.com/pingcap/tidb-tools/pkg/filter" | ||
"github.com/pingcap/tidb/config" | ||
"github.com/spf13/pflag" | ||
"go.uber.org/zap" | ||
|
||
|
@@ -23,8 +24,9 @@ import ( | |
) | ||
|
||
const ( | ||
flagOnline = "online" | ||
flagNoSchema = "no-schema" | ||
flagOnline = "online" | ||
flagNoSchema = "no-schema" | ||
flagMaxIndexLength = "max-index-length" | ||
) | ||
|
||
var schedulers = map[string]struct{}{ | ||
|
@@ -46,18 +48,21 @@ const ( | |
type RestoreConfig struct { | ||
Config | ||
|
||
Online bool `json:"online" toml:"online"` | ||
NoSchema bool `json:"no-schema" toml:"no-schema"` | ||
Online bool `json:"online" toml:"online"` | ||
NoSchema bool `json:"no-schema" toml:"no-schema"` | ||
MaxIndexLength int `json:"max-index-length" toml:"max-index-length"` | ||
} | ||
|
||
// DefineRestoreFlags defines common flags for the restore command. | ||
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. | ||
|
@@ -71,6 +76,10 @@ 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) | ||
|
@@ -148,6 +157,12 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf | |
return err | ||
} | ||
// execute DDL first | ||
|
||
// set max index length before execute DDLs and create tables | ||
conf := config.GetGlobalConfig() | ||
conf.MaxIndexLength = cfg.MaxIndexLength | ||
config.StoreGlobalConfig(conf) | ||
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. Better to log a warning or explain it in our document. 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. okay,add a warn log |
||
|
||
err = client.ExecDDLs(ddlJobs) | ||
if err != nil { | ||
return errors.Trace(err) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.