diff --git a/ddl/backfilling.go b/ddl/backfilling.go index e33229cac4ddf..5c6156cd738a4 100644 --- a/ddl/backfilling.go +++ b/ddl/backfilling.go @@ -217,8 +217,8 @@ type backfillCtx struct { } func newBackfillCtx(ctx *ddlCtx, id int, sessCtx sessionctx.Context, reorgTp model.ReorgType, - schemaName string, tbl table.Table) *backfillCtx { - if id == 0 { + schemaName string, tbl table.Table, isDistributed bool) *backfillCtx { + if isDistributed { id = int(backfillContextID.Add(1)) } return &backfillCtx{ @@ -918,7 +918,7 @@ func (b *backfillScheduler) adjustWorkerSize() error { ) switch b.tp { case typeAddIndexWorker: - backfillCtx := newBackfillCtx(reorgInfo.d, i, sessCtx, reorgInfo.ReorgMeta.ReorgTp, job.SchemaName, b.tbl) + backfillCtx := newBackfillCtx(reorgInfo.d, i, sessCtx, reorgInfo.ReorgMeta.ReorgTp, job.SchemaName, b.tbl, false) idxWorker, err := newAddIndexWorker(b.decodeColMap, b.tbl, backfillCtx, jc, job.ID, reorgInfo.currElement.ID, reorgInfo.currElement.TypeKey) if err != nil { @@ -931,7 +931,7 @@ func (b *backfillScheduler) adjustWorkerSize() error { runner = newBackfillWorker(jc.ddlJobCtx, idxWorker) worker = idxWorker case typeAddIndexMergeTmpWorker: - backfillCtx := newBackfillCtx(reorgInfo.d, i, sessCtx, reorgInfo.ReorgMeta.ReorgTp, job.SchemaName, b.tbl) + backfillCtx := newBackfillCtx(reorgInfo.d, i, sessCtx, reorgInfo.ReorgMeta.ReorgTp, job.SchemaName, b.tbl, false) tmpIdxWorker := newMergeTempIndexWorker(backfillCtx, i, b.tbl, reorgInfo.currElement.ID, jc) runner = newBackfillWorker(jc.ddlJobCtx, tmpIdxWorker) worker = tmpIdxWorker diff --git a/ddl/column.go b/ddl/column.go index 3c5eeb995c0c4..380c1604d5c97 100644 --- a/ddl/column.go +++ b/ddl/column.go @@ -1172,7 +1172,7 @@ func newUpdateColumnWorker(sessCtx sessionctx.Context, id int, t table.PhysicalT } rowDecoder := decoder.NewRowDecoder(t, t.WritableCols(), decodeColMap) return &updateColumnWorker{ - backfillCtx: newBackfillCtx(reorgInfo.d, id, sessCtx, reorgInfo.ReorgMeta.ReorgTp, reorgInfo.SchemaName, t), + backfillCtx: newBackfillCtx(reorgInfo.d, id, sessCtx, reorgInfo.ReorgMeta.ReorgTp, reorgInfo.SchemaName, t, false), oldColInfo: oldCol, newColInfo: newCol, metricCounter: metrics.BackfillTotalCounter.WithLabelValues(metrics.GenerateReorgLabel("update_col_rate", reorgInfo.SchemaName, t.Meta().Name.String())), diff --git a/ddl/dist_backfilling.go b/ddl/dist_backfilling.go index 59f9b17506543..e534833b377df 100644 --- a/ddl/dist_backfilling.go +++ b/ddl/dist_backfilling.go @@ -74,7 +74,7 @@ func newBackfillWorkerContext(d *ddl, schemaName string, tbl table.Table, worker } var bf backfiller - bf, err = bfFunc(newBackfillCtx(d.ddlCtx, 0, se, bfMeta.ReorgTp, schemaName, tbl)) + bf, err = bfFunc(newBackfillCtx(d.ddlCtx, 0, se, bfMeta.ReorgTp, schemaName, tbl, true)) if err != nil { if canSkipError(jobID, len(bwCtx.backfillWorkers), err) { err = nil diff --git a/ddl/index.go b/ddl/index.go index 4785b12e41090..3578ca0ed4537 100644 --- a/ddl/index.go +++ b/ddl/index.go @@ -1961,7 +1961,7 @@ func newCleanUpIndexWorker(sessCtx sessionctx.Context, id int, t table.PhysicalT } return &cleanUpIndexWorker{ baseIndexWorker: baseIndexWorker{ - backfillCtx: newBackfillCtx(reorgInfo.d, id, sessCtx, reorgInfo.ReorgMeta.ReorgTp, reorgInfo.SchemaName, t), + backfillCtx: newBackfillCtx(reorgInfo.d, id, sessCtx, reorgInfo.ReorgMeta.ReorgTp, reorgInfo.SchemaName, t, false), indexes: indexes, rowDecoder: rowDecoder, defaultVals: make([]types.Datum, len(t.WritableCols())),