Skip to content
Open
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
13 changes: 12 additions & 1 deletion pkg/ddl/backfilling_dist_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ import (
"go.uber.org/zap"
)

var errBackfillTaskMetaOutdated = errors.New("backfill task meta is outdated")

func isBackfillTaskMetaOutdatedErr(err error) bool {
return errors.Cause(err) == errBackfillTaskMetaOutdated
}

// Version constants for BackfillTaskMeta.
const (
BackfillTaskMetaVersion0 = iota
Expand Down Expand Up @@ -164,7 +170,9 @@ func (s *backfillDistExecutor) newBackfillStepExecutor(
logutil.DDLIngestLogger().Warn("index info not found",
zap.Int64("table ID", tbl.Meta().ID),
zap.Int64("index ID", eid))
return nil, errors.Errorf("index info not found: %d", eid)
return nil, errors.Annotatef(errBackfillTaskMetaOutdated,
"index info not found: %d, table ID: %d, job ID: %d",
eid, tbl.Meta().ID, jobMeta.ID)
}
indexInfos = append(indexInfos, indexInfo)
}
Expand Down Expand Up @@ -246,6 +254,9 @@ func (*backfillDistExecutor) IsIdempotent(*proto.Subtask) bool {
}

func (*backfillDistExecutor) IsRetryableError(err error) bool {
if isBackfillTaskMetaOutdatedErr(err) {
return false
}
return common.IsRetryableError(err) || isRetryableError(err, true)
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/ddl/backfilling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"
"time"

"github.com/pingcap/errors"
"github.com/pingcap/tidb/pkg/ddl/copr"
"github.com/pingcap/tidb/pkg/ddl/ingest"
distsqlctx "github.com/pingcap/tidb/pkg/distsql/context"
Expand Down Expand Up @@ -64,6 +65,12 @@ func TestDoneTaskKeeper(t *testing.T) {
require.True(t, bytes.Equal(n.nextKey, kv.Key("h")))
}

func TestOutdatedBackfillTaskMetaIsNonRetryable(t *testing.T) {
err := errors.Annotatef(errBackfillTaskMetaOutdated, "index info not found: %d", 1)
require.False(t, isRetryableError(err, true))
require.False(t, (&backfillDistExecutor{}).IsRetryableError(err))
}

func TestPickBackfillType(t *testing.T) {
ingest.LitDiskRoot = ingest.NewDiskRootImpl(t.TempDir())
ingest.LitMemRoot = ingest.NewMemRootImpl(math.MaxInt64)
Expand Down
3 changes: 3 additions & 0 deletions pkg/ddl/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,9 @@ func isRetryableJobError(err error, jobErrCnt int64) bool {
}

func isRetryableError(err error, retryUnknown bool) bool {
if isBackfillTaskMetaOutdatedErr(err) {
return false
}
errMsg := err.Error()
for _, m := range dbterror.ReorgRetryableErrMsgs {
if strings.Contains(errMsg, m) {
Expand Down
Loading