diff --git a/br/pkg/task/restore.go b/br/pkg/task/restore.go index 25056510ffc20..2a5c58a9febf3 100644 --- a/br/pkg/task/restore.go +++ b/br/pkg/task/restore.go @@ -491,7 +491,7 @@ func IsStreamRestore(cmdName string) bool { // RunRestore starts a restore task inside the current goroutine. func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConfig) error { if err := checkTaskExists(c, cfg); err != nil { - return errors.Trace(err) + return errors.Annotate(err, "failed to check task exits") } config.UpdateGlobal(func(conf *config.Config) { diff --git a/br/pkg/task/stream.go b/br/pkg/task/stream.go index 83c85356691f1..942b1faefdc7c 100644 --- a/br/pkg/task/stream.go +++ b/br/pkg/task/stream.go @@ -1045,7 +1045,11 @@ func checkTaskExists(ctx context.Context, cfg *RestoreConfig) error { return err } cli := streamhelper.NewMetaDataClient(etcdCLI) - defer cli.Close() + defer func() { + if err := cli.Close(); err != nil { + log.Error("failed to close the etcd client", zap.Error(err)) + } + }() tasks, err := cli.GetAllTasks(ctx) if err != nil { return err