diff --git a/br/pkg/backup/client.go b/br/pkg/backup/client.go index 12a4344a432fe..7a4b1e0e8eb66 100644 --- a/br/pkg/backup/client.go +++ b/br/pkg/backup/client.go @@ -470,7 +470,13 @@ func (bc *Client) BackupRanges( elctx := logutil.ContextWithField(ectx, logutil.RedactAny("range-sn", id)) err := bc.BackupRange(elctx, sk, ek, req, metaWriter, progressCallBack) if err != nil { - return errors.Trace(err) + // The error due to context cancel, stack trace is meaningless, the stack shall be suspended (also clear) + if errors.Cause(err) == context.Canceled { + return errors.SuspendStack(err) + } else { + return errors.Trace(err) + } + } return nil }) diff --git a/br/pkg/summary/collector.go b/br/pkg/summary/collector.go index 5493f82f77967..6c82bf54fba25 100644 --- a/br/pkg/summary/collector.go +++ b/br/pkg/summary/collector.go @@ -3,11 +3,13 @@ package summary import ( + "context" "strings" "sync" "time" "github.com/docker/go-units" + berror "github.com/pingcap/errors" "github.com/pingcap/log" "go.uber.org/zap" ) @@ -188,9 +190,16 @@ func (tc *logCollector) Summary(name string) { } if len(tc.failureReasons) != 0 || !tc.successStatus { + var canceledUnits int for unitName, reason := range tc.failureReasons { - logFields = append(logFields, zap.String("unit-name", unitName), zap.Error(reason)) + if berror.Cause(reason) != context.Canceled { + logFields = append(logFields, zap.String("unit-name", unitName), zap.Error(reason)) + } else { + canceledUnits++ + } } + // only print total number of cancel unit + log.Info("units canceled", zap.Int("cancel-unit", canceledUnits)) tc.log(name+" failed summary", logFields...) return }