diff --git a/pkg/ccl/backupccl/backup_processor_planning.go b/pkg/ccl/backupccl/backup_processor_planning.go index c919412ad316..4e76acf31d78 100644 --- a/pkg/ccl/backupccl/backup_processor_planning.go +++ b/pkg/ccl/backupccl/backup_processor_planning.go @@ -212,7 +212,7 @@ func distBackup( defer close(progCh) execCfg := execCtx.ExecCfg() - jobsprofiler.StorePlanDiagram(ctx, execCfg.DistSQLSrv.Stopper, p, execCfg.InternalDB, jobID) + jobsprofiler.StorePlanDiagram(ctx, execCfg.DistSQLSrv.Stopper, p, execCfg.InternalDB, jobID, execCfg.Settings.Version) // Copy the evalCtx, as dsp.Run() might change it. evalCtxCopy := *evalCtx diff --git a/pkg/ccl/backupccl/restore_processor_planning.go b/pkg/ccl/backupccl/restore_processor_planning.go index 45c8cf301219..1c4f95fdeca4 100644 --- a/pkg/ccl/backupccl/restore_processor_planning.go +++ b/pkg/ccl/backupccl/restore_processor_planning.go @@ -299,7 +299,7 @@ func distRestore( defer recv.Release() execCfg := execCtx.ExecCfg() - jobsprofiler.StorePlanDiagram(ctx, execCfg.DistSQLSrv.Stopper, p, execCfg.InternalDB, jobID) + jobsprofiler.StorePlanDiagram(ctx, execCfg.DistSQLSrv.Stopper, p, execCfg.InternalDB, jobID, execCfg.Settings.Version) // Copy the evalCtx, as dsp.Run() might change it. evalCtxCopy := *evalCtx diff --git a/pkg/ccl/changefeedccl/changefeed_dist.go b/pkg/ccl/changefeedccl/changefeed_dist.go index 39e343014a8f..9bf8b159028e 100644 --- a/pkg/ccl/changefeedccl/changefeed_dist.go +++ b/pkg/ccl/changefeedccl/changefeed_dist.go @@ -320,7 +320,7 @@ func startDistChangefeed( finishedSetupFn = func(flowinfra.Flow) { resultsCh <- tree.Datums(nil) } } - jobsprofiler.StorePlanDiagram(ctx, execCfg.DistSQLSrv.Stopper, p, execCfg.InternalDB, jobID) + jobsprofiler.StorePlanDiagram(ctx, execCfg.DistSQLSrv.Stopper, p, execCfg.InternalDB, jobID, execCfg.Settings.Version) // Copy the evalCtx, as dsp.Run() might change it. evalCtxCopy := *evalCtx diff --git a/pkg/ccl/streamingccl/streamingest/stream_ingestion_dist.go b/pkg/ccl/streamingccl/streamingest/stream_ingestion_dist.go index 630613dd7128..d186de921772 100644 --- a/pkg/ccl/streamingccl/streamingest/stream_ingestion_dist.go +++ b/pkg/ccl/streamingccl/streamingest/stream_ingestion_dist.go @@ -107,7 +107,7 @@ func startDistIngestion( defer recv.Release() jobsprofiler.StorePlanDiagram(ctx, execCtx.ExecCfg().DistSQLSrv.Stopper, p, execCtx.ExecCfg().InternalDB, - ingestionJob.ID()) + ingestionJob.ID(), execCtx.ExecCfg().Settings.Version) // Copy the evalCtx, as dsp.Run() might change it. evalCtxCopy := *execCtx.ExtendedEvalContext() diff --git a/pkg/jobs/jobsprofiler/BUILD.bazel b/pkg/jobs/jobsprofiler/BUILD.bazel index 2f87f21f0d30..b55f7ef01bde 100644 --- a/pkg/jobs/jobsprofiler/BUILD.bazel +++ b/pkg/jobs/jobsprofiler/BUILD.bazel @@ -6,6 +6,7 @@ go_library( importpath = "github.com/cockroachdb/cockroach/pkg/jobs/jobsprofiler", visibility = ["//visibility:public"], deps = [ + "//pkg/clusterversion", "//pkg/jobs", "//pkg/jobs/jobspb", "//pkg/sql", diff --git a/pkg/jobs/jobsprofiler/profiler.go b/pkg/jobs/jobsprofiler/profiler.go index a0145961736f..28a4d1bb23f0 100644 --- a/pkg/jobs/jobsprofiler/profiler.go +++ b/pkg/jobs/jobsprofiler/profiler.go @@ -14,6 +14,7 @@ import ( "context" "fmt" + "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/jobs" "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" "github.com/cockroachdb/cockroach/pkg/sql" @@ -28,8 +29,17 @@ import ( // table. The generation of the plan diagram and persistence to the info table // are done asynchronously and this method does not block on their completion. func StorePlanDiagram( - ctx context.Context, stopper *stop.Stopper, p *sql.PhysicalPlan, db isql.DB, jobID jobspb.JobID, + ctx context.Context, + stopper *stop.Stopper, + p *sql.PhysicalPlan, + db isql.DB, + jobID jobspb.JobID, + cv clusterversion.Handle, ) { + if !cv.IsActive(ctx, clusterversion.V23_1) { + return + } + if err := stopper.RunAsyncTask(ctx, "jobs-store-plan-diagram", func(ctx context.Context) { var cancel func() ctx, cancel = stopper.WithCancelOnQuiesce(ctx) diff --git a/pkg/sql/importer/import_processor_planning.go b/pkg/sql/importer/import_processor_planning.go index 86ea46d3a5af..e79b3811ca07 100644 --- a/pkg/sql/importer/import_processor_planning.go +++ b/pkg/sql/importer/import_processor_planning.go @@ -270,7 +270,7 @@ func distImport( } execCfg := execCtx.ExecCfg() - jobsprofiler.StorePlanDiagram(ctx, execCfg.DistSQLSrv.Stopper, p, execCfg.InternalDB, job.ID()) + jobsprofiler.StorePlanDiagram(ctx, execCfg.DistSQLSrv.Stopper, p, execCfg.InternalDB, job.ID(), execCtx.ExecCfg().Settings.Version) // Copy the evalCtx, as dsp.Run() might change it. evalCtxCopy := *evalCtx