diff --git a/pkg/ddl/ddl_worker.go b/pkg/ddl/ddl_worker.go index 029c16f00f058..96d59251ff32b 100644 --- a/pkg/ddl/ddl_worker.go +++ b/pkg/ddl/ddl_worker.go @@ -117,6 +117,7 @@ type JobContext struct { tp string resourceGroupName string + cloudStorageURI string } // NewJobContext returns a new ddl job context. diff --git a/pkg/ddl/index.go b/pkg/ddl/index.go index f8b5dca53d97f..70f16e0ecec5d 100644 --- a/pkg/ddl/index.go +++ b/pkg/ddl/index.go @@ -644,6 +644,7 @@ SwitchIndexState: } return ver, err } + loadCloudStorageURI(w, job) if reorgTp.NeedMergeProcess() { // Increase telemetryAddIndexIngestUsage telemetryAddIndexIngestUsage.Inc() @@ -791,6 +792,12 @@ func pickBackfillType(ctx context.Context, job *model.Job, unique bool, d *ddlCt return model.ReorgTypeTxnMerge, nil } +func loadCloudStorageURI(w *worker, job *model.Job) { + jc := w.jobContext(job.ID, job.ReorgMeta) + jc.cloudStorageURI = variable.CloudStorageURI.Load() + job.ReorgMeta.UseCloudStorage = len(jc.cloudStorageURI) > 0 +} + // cleanupSortPath is used to clean up the temp data of the previous jobs. // Because we don't remove all the files after the support of checkpoint, // there maybe some stale files in the sort path if TiDB is killed during the backfill process. @@ -2111,11 +2118,12 @@ func (w *worker) executeDistGlobalTask(reorgInfo *reorgInfo) error { elemIDs = append(elemIDs, elem.ID) } + job := reorgInfo.Job taskMeta := &BackfillGlobalMeta{ Job: *reorgInfo.Job.Clone(), EleIDs: elemIDs, EleTypeKey: reorgInfo.currElement.TypeKey, - CloudStorageURI: variable.CloudStorageURI.Load(), + CloudStorageURI: w.jobContext(job.ID, job.ReorgMeta).cloudStorageURI, } metaData, err := json.Marshal(taskMeta) diff --git a/pkg/ddl/multi_schema_change.go b/pkg/ddl/multi_schema_change.go index 1380aeb25241f..9956446910e7a 100644 --- a/pkg/ddl/multi_schema_change.go +++ b/pkg/ddl/multi_schema_change.go @@ -198,6 +198,7 @@ func appendToSubJobs(m *model.MultiSchemaInfo, job *model.Job) error { Revertible: true, CtxVars: job.CtxVars, ReorgTp: reorgTp, + UseCloud: false, }) return nil } diff --git a/pkg/executor/executor.go b/pkg/executor/executor.go index d94a7b924fed4..c595b6db6b681 100644 --- a/pkg/executor/executor.go +++ b/pkg/executor/executor.go @@ -520,10 +520,17 @@ func (e *DDLJobRetriever) appendJobToChunk(req *chunk.Chunk, job *model.Job, che func showAddIdxReorgTp(job *model.Job) string { if job.Type == model.ActionAddIndex || job.Type == model.ActionAddPrimaryKey { if job.ReorgMeta != nil { + sb := strings.Builder{} tp := job.ReorgMeta.ReorgTp.String() if len(tp) > 0 { - return " /* " + tp + " */" + sb.WriteString(" /* ") + sb.WriteString(tp) + if job.ReorgMeta.UseCloudStorage { + sb.WriteString(" cloud") + } + sb.WriteString(" */") } + return sb.String() } } return "" @@ -531,10 +538,17 @@ func showAddIdxReorgTp(job *model.Job) string { func showAddIdxReorgTpInSubJob(subJob *model.SubJob) string { if subJob.Type == model.ActionAddIndex || subJob.Type == model.ActionAddPrimaryKey { + sb := strings.Builder{} tp := subJob.ReorgTp.String() if len(tp) > 0 { - return " /* " + tp + " */" + sb.WriteString(" /* ") + sb.WriteString(tp) + if subJob.UseCloud { + sb.WriteString(" cloud") + } + sb.WriteString(" */") } + return sb.String() } return "" } diff --git a/pkg/parser/model/ddl.go b/pkg/parser/model/ddl.go index ec12b06bde7ae..f0aa1af73e1c8 100644 --- a/pkg/parser/model/ddl.go +++ b/pkg/parser/model/ddl.go @@ -301,6 +301,7 @@ type SubJob struct { CtxVars []interface{} `json:"-"` SchemaVer int64 `json:"schema_version"` ReorgTp ReorgType `json:"reorg_tp"` + UseCloud bool `json:"use_cloud"` } // IsNormal returns true if the sub-job is normally running. @@ -369,6 +370,7 @@ func (sub *SubJob) FromProxyJob(proxyJob *Job, ver int64) { sub.RowCount = proxyJob.RowCount sub.SchemaVer = ver sub.ReorgTp = proxyJob.ReorgMeta.ReorgTp + sub.UseCloud = proxyJob.ReorgMeta.UseCloudStorage } // JobMeta is meta info of Job. diff --git a/pkg/parser/model/reorg.go b/pkg/parser/model/reorg.go index 25cd9f287ac5a..68a9f27a0d374 100644 --- a/pkg/parser/model/reorg.go +++ b/pkg/parser/model/reorg.go @@ -29,6 +29,7 @@ type DDLReorgMeta struct { Location *TimeZoneLocation `json:"location"` ReorgTp ReorgType `json:"reorg_tp"` IsDistReorg bool `json:"is_dist_reorg"` + UseCloudStorage bool `json:"use_cloud_storage"` ResourceGroupName string `json:"resource_group_name"` Version int64 `json:"version"` }