From c8a21125b611a5f0eda833b7e79fc46d2c89b02f Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Mon, 9 Oct 2023 11:04:53 +0800 Subject: [PATCH] ddl: no more sleep when meets nonRetryable error (#47461) close pingcap/tidb#47455 --- ddl/ddl_worker.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ddl/ddl_worker.go b/ddl/ddl_worker.go index dbd519b79f116..afd520b24182b 100644 --- a/ddl/ddl_worker.go +++ b/ddl/ddl_worker.go @@ -40,7 +40,6 @@ import ( pumpcli "github.com/pingcap/tidb/tidb-binlog/pump_client" tidbutil "github.com/pingcap/tidb/util" "github.com/pingcap/tidb/util/dbterror" - "github.com/pingcap/tidb/util/intest" "github.com/pingcap/tidb/util/logutil" "github.com/pingcap/tidb/util/mathutil" "github.com/pingcap/tidb/util/resourcegrouptag" @@ -835,16 +834,13 @@ func (w *worker) HandleDDLJobTable(d *ddlCtx, job *model.Job) (int64, error) { } w.registerSync(job) - if runJobErr != nil && !dbterror.ErrPausedDDLJob.Equal(runJobErr) { - // Omit the ErrPausedDDLJob + // If error is non-retryable, we can ignore the sleep. + if runJobErr != nil && errorIsRetryable(runJobErr, job) { w.jobLogger(job).Info("run DDL job failed, sleeps a while then retries it.", zap.Duration("waitTime", GetWaitTimeWhenErrorOccurred()), zap.Error(runJobErr)) - // In test and job is cancelling we can ignore the sleep. - if !(intest.InTest && job.IsCancelling()) { - // wait a while to retry again. If we don't wait here, DDL will retry this job immediately, - // which may act like a deadlock. - time.Sleep(GetWaitTimeWhenErrorOccurred()) - } + // wait a while to retry again. If we don't wait here, DDL will retry this job immediately, + // which may act like a deadlock. + time.Sleep(GetWaitTimeWhenErrorOccurred()) } return schemaVer, nil