Skip to content

Commit

Permalink
summary: put summary log at last (pingcap#197)
Browse files Browse the repository at this point in the history
* summary: put summary log at last

* fix switch sql
  • Loading branch information
3pointer authored Mar 19, 2020
1 parent 6268cde commit 4ea6c1c
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pkg/restore/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewDB(g glue.Glue, store kv.Storage) (*DB, error) {
func (db *DB) ExecDDL(ctx context.Context, ddlJob *model.Job) error {
var err error
if ddlJob.BinlogInfo.TableInfo != nil {
switchDbSQL := fmt.Sprintf("use %s;", ddlJob.SchemaName)
switchDbSQL := fmt.Sprintf("use %s;", utils.EncloseName(ddlJob.SchemaName))
err = db.se.Execute(ctx, switchDbSQL)
if err != nil {
log.Error("switch db failed",
Expand Down
3 changes: 1 addition & 2 deletions pkg/task/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (cfg *BackupConfig) ParseFromFlags(flags *pflag.FlagSet) error {

// RunBackup starts a backup task inside the current goroutine.
func RunBackup(c context.Context, g glue.Glue, cmdName string, cfg *BackupConfig) error {
defer summary.Summary(cmdName)
ctx, cancel := context.WithCancel(c)
defer cancel()

Expand Down Expand Up @@ -121,8 +122,6 @@ func RunBackup(c context.Context, g glue.Glue, cmdName string, cfg *BackupConfig
return err
}

defer summary.Summary(cmdName)

ranges, backupSchemas, err := backup.BuildBackupRangeAndSchema(
mgr.GetDomain(), mgr.GetTiKV(), tableFilter, backupTS)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/task/backup_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (cfg *RawKvConfig) ParseFromFlags(flags *pflag.FlagSet) error {

// RunBackupRaw starts a backup task inside the current goroutine.
func RunBackupRaw(c context.Context, g glue.Glue, cmdName string, cfg *RawKvConfig) error {
defer summary.Summary(cmdName)
ctx, cancel := context.WithCancel(c)
defer cancel()

Expand All @@ -104,8 +105,6 @@ func RunBackupRaw(c context.Context, g glue.Glue, cmdName string, cfg *RawKvConf
return err
}

defer summary.Summary(cmdName)

backupRange := rtree.Range{StartKey: cfg.StartKey, EndKey: cfg.EndKey}

// The number of regions need to backup
Expand Down
3 changes: 1 addition & 2 deletions pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (cfg *RestoreConfig) ParseFromFlags(flags *pflag.FlagSet) error {

// RunRestore starts a restore task inside the current goroutine.
func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConfig) error {
defer summary.Summary(cmdName)
ctx, cancel := context.WithCancel(c)
defer cancel()

Expand Down Expand Up @@ -105,8 +106,6 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
return err
}

defer summary.Summary(cmdName)

u, _, backupMeta, err := ReadBackupMeta(ctx, utils.MetaFile, &cfg.Config)
if err != nil {
return err
Expand Down
3 changes: 1 addition & 2 deletions pkg/task/restore_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (cfg *RestoreRawConfig) ParseFromFlags(flags *pflag.FlagSet) error {

// RunRestoreRaw starts a raw kv restore task inside the current goroutine.
func RunRestoreRaw(c context.Context, g glue.Glue, cmdName string, cfg *RestoreRawConfig) error {
defer summary.Summary(cmdName)
ctx, cancel := context.WithCancel(c)
defer cancel()

Expand All @@ -67,8 +68,6 @@ func RunRestoreRaw(c context.Context, g glue.Glue, cmdName string, cfg *RestoreR
client.EnableOnline()
}

defer summary.Summary(cmdName)

u, _, backupMeta, err := ReadBackupMeta(ctx, utils.MetaFile, &cfg.Config)
if err != nil {
return err
Expand Down

0 comments on commit 4ea6c1c

Please sign in to comment.