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

task: do not run checksum if restore failed #209

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
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