Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Max index length #220

Merged
merged 5 commits into from
Apr 2, 2020
Merged
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
23 changes: 19 additions & 4 deletions pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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{}{
Expand All @@ -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")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
flags.Int(flagMaxIndexLength, 3072, "need keep this as same as tidb max-index-length")
flags.Int(flagMaxIndexLength, 3072, "value of max-index-length setting of the restored TiDB")


// Do not expose this flag
_ = flags.MarkHidden(flagNoSchema)
_ = flags.MarkHidden(flagMaxIndexLength)
}

// ParseFromFlags parses the restore-related flags from the flag set.
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to log a warning or explain it in our document.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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)
Expand Down