diff --git a/ddl/backfilling.go b/ddl/backfilling.go index fe84ab24f24bc..25881476c71da 100644 --- a/ddl/backfilling.go +++ b/ddl/backfilling.go @@ -220,8 +220,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{ @@ -921,7 +921,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 { @@ -934,7 +934,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 d8ece435e28a8..9664774c2dfdc 100644 --- a/ddl/column.go +++ b/ddl/column.go @@ -1205,7 +1205,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 9b2524beb86c5..b030cb33f0488 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 4559a39738c55..736fce54bcfcf 100644 --- a/ddl/index.go +++ b/ddl/index.go @@ -1985,7 +1985,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())), diff --git a/ddl/partition.go b/ddl/partition.go index 00a5582be9a54..635ebaa051cd3 100644 --- a/ddl/partition.go +++ b/ddl/partition.go @@ -2576,7 +2576,7 @@ func newReorgPartitionWorker(sessCtx sessionctx.Context, i int, t table.Physical maxOffset = mathutil.Max[int](maxOffset, col.Offset) } return &reorgPartitionWorker{ - backfillCtx: newBackfillCtx(reorgInfo.d, i, sessCtx, reorgInfo.ReorgMeta.ReorgTp, reorgInfo.SchemaName, t), + backfillCtx: newBackfillCtx(reorgInfo.d, i, sessCtx, reorgInfo.ReorgMeta.ReorgTp, reorgInfo.SchemaName, t, false), metricCounter: metrics.BackfillTotalCounter.WithLabelValues(metrics.GenerateReorgLabel("reorg_partition_rate", reorgInfo.SchemaName, t.Meta().Name.String())), rowDecoder: decoder.NewRowDecoder(t, t.WritableCols(), decodeColMap), rowMap: make(map[int64]types.Datum, len(decodeColMap)),