Skip to content

Commit

Permalink
task: do not run checksum if restore failed (pingcap#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm authored Mar 26, 2020
1 parent ae7688a commit 8638d9a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
12 changes: 8 additions & 4 deletions pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,16 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf

// Always run the post-work even on error, so we don't stuck in the import
// mode or emptied schedulers
err = restorePostWork(ctx, client, mgr, clusterCfg)
if err != nil {
return err
if errRestorePostWork := restorePostWork(ctx, client, mgr, clusterCfg); err == nil {
err = errRestorePostWork
}

if err = splitPostWork(ctx, client, newTables); err != nil {
if errSplitPostWork := splitPostWork(ctx, client, newTables); err == nil {
err = errSplitPostWork
}

// If any error happened, return now, don't execute checksum.
if err != nil {
return err
}

Expand Down
12 changes: 7 additions & 5 deletions pkg/task/restore_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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 {
func RunRestoreRaw(c context.Context, g glue.Glue, cmdName string, cfg *RestoreRawConfig) (err error) {
defer summary.Summary(cmdName)
ctx, cancel := context.WithCancel(c)
defer cancel()
Expand Down Expand Up @@ -113,16 +113,18 @@ func RunRestoreRaw(c context.Context, g glue.Glue, cmdName string, cfg *RestoreR
if err != nil {
return errors.Trace(err)
}
defer func() {
errPostWork := restorePostWork(ctx, client, mgr, removedSchedulers)
if err == nil {
err = errPostWork
}
}()

err = client.RestoreRaw(cfg.StartKey, cfg.EndKey, files, updateCh)
if err != nil {
return errors.Trace(err)
}

err = restorePostWork(ctx, client, mgr, removedSchedulers)
if err != nil {
return errors.Trace(err)
}
// Restore has finished.
updateCh.Close()

Expand Down

0 comments on commit 8638d9a

Please sign in to comment.