Skip to content

Commit

Permalink
sql,*: remove DistributionTypeSystemTenantOnly
Browse files Browse the repository at this point in the history
Uses of DistributionTypeSystemTenantOnly represent places where UA/MT
performance may not match single-tenant performance.

This replaces all uses of DistributionTypeSystemTenantOnly with
DistributionTypeAlways.

Epic: none

Fixes cockroachdb#116534
  • Loading branch information
stevendanna authored and jasminejsun committed Mar 18, 2024
1 parent 3583e92 commit be112f2
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/streamingccl/streamproducer/stream_lifetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func buildReplicationStreamSpec(
// Partition the spans with SQLPlanner
dsp := jobExecCtx.DistSQLPlanner()
planCtx := dsp.NewPlanningCtx(ctx, jobExecCtx.ExtendedEvalContext(),
nil /* planner */, nil /* txn */, sql.DistributionTypeSystemTenantOnly)
nil /* planner */, nil /* txn */, sql.DistributionTypeAlways)

spanPartitions, err := dsp.PartitionSpans(ctx, planCtx, targetSpans)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ func (sc *SchemaChanger) distIndexBackfill(
sd := NewInternalSessionData(ctx, sc.execCfg.Settings, "dist-index-backfill")
evalCtx = createSchemaChangeEvalCtx(ctx, sc.execCfg, sd, txn.KV().ReadTimestamp(), txn.Descriptors())
planCtx = sc.distSQLPlanner.NewPlanningCtx(ctx, &evalCtx, nil, /* planner */
txn.KV(), DistributionTypeSystemTenantOnly)
txn.KV(), DistributionTypeAlways)
indexBatchSize := indexBackfillBatchSize.Get(&sc.execCfg.Settings.SV)
chunkSize := sc.getChunkSize(indexBatchSize)
spec, err := initIndexBackfillerSpec(*tableDesc.TableDesc(), writeAsOf, readAsOf, writeAtRequestTimestamp, chunkSize, addedIndexes)
Expand Down Expand Up @@ -1352,7 +1352,7 @@ func (sc *SchemaChanger) distColumnBackfill(
defer recv.Release()

planCtx := sc.distSQLPlanner.NewPlanningCtx(ctx, &evalCtx, nil /* planner */, txn.KV(),
DistributionTypeSystemTenantOnly)
DistributionTypeAlways)
spec, err := initColumnBackfillerSpec(tableDesc, duration, chunkSize, backfillUpdateChunkSizeThresholdBytes, readAsOf)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/create_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ func (r *createStatsResumer) Resume(ctx context.Context, execCtx interface{}) er
}

planCtx := dsp.NewPlanningCtx(ctx, evalCtx, nil /* planner */, txn.KV(),
DistributionTypeSystemTenantOnly)
DistributionTypeAlways)
// CREATE STATS flow doesn't produce any rows and only emits the
// metadata, so we can use a nil rowContainerHelper.
resultWriter := NewRowResultWriter(nil /* rowContainer */)
Expand Down
5 changes: 1 addition & 4 deletions pkg/sql/distsql_physical_planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ const (
// DistributionTypeAlways distributes a plan across multiple instances whether
// it is a system tenant or non-system tenant.
DistributionTypeAlways
// DistributionTypeSystemTenantOnly only distributes a plan if it is for a
// system tenant. Plans on non-system tenants are not distributed.
DistributionTypeSystemTenantOnly
)

// ReplicaOraclePolicy controls which policy the physical planner uses to choose
Expand Down Expand Up @@ -4840,7 +4837,7 @@ func (dsp *DistSQLPlanner) NewPlanningCtxWithOracle(
oracle replicaoracle.Oracle,
localityFiler roachpb.Locality,
) *PlanningCtx {
distribute := distributionType == DistributionTypeAlways || (distributionType == DistributionTypeSystemTenantOnly && evalCtx.Codec.ForSystemTenant())
distribute := distributionType == DistributionTypeAlways
infra := physicalplan.NewPhysicalInfrastructure(uuid.FastMakeV4(), dsp.gatewaySQLInstanceID)
planCtx := &PlanningCtx{
ExtendedEvalCtx: evalCtx,
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/distsql_physical_planner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ func TestPartitionSpans(t *testing.T) {
}
planCtx := dsp.NewPlanningCtxWithOracle(ctx, &extendedEvalContext{
Context: *evalCtx,
}, nil, nil, DistributionTypeSystemTenantOnly, physicalplan.DefaultReplicaChooser, locFilter)
}, nil, nil, DistributionTypeAlways, physicalplan.DefaultReplicaChooser, locFilter)
planCtx.spanPartitionState.testingOverrideRandomSelection = tc.partitionState.testingOverrideRandomSelection
var spans []roachpb.Span
for _, s := range tc.spans {
Expand Down Expand Up @@ -1515,7 +1515,7 @@ func TestPartitionSpansSkipsNodesNotInGossip(t *testing.T) {
ctx := context.Background()
planCtx := dsp.NewPlanningCtx(ctx, &extendedEvalContext{
Context: eval.Context{Codec: keys.SystemSQLCodec},
}, nil, nil, DistributionTypeSystemTenantOnly)
}, nil, nil, DistributionTypeAlways)
partitions, err := dsp.PartitionSpans(ctx, planCtx, roachpb.Spans{span})
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/distsql_plan_ctas.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func PlanAndRunCTAS(
) {
distribute := DistributionType(DistributionTypeNone)
if !isLocal {
distribute = DistributionTypeSystemTenantOnly
distribute = DistributionTypeAlways
}
planCtx := dsp.NewPlanningCtx(ctx, planner.ExtendedEvalContext(), planner,
txn, distribute)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/distsql_running_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func TestDistSQLRunningInAbortedTxn(t *testing.T) {
// the root txn meta to leaf txns. Local flows can start in aborted txns
// because they just use the root txn.
planCtx := execCfg.DistSQLPlanner.NewPlanningCtx(ctx, evalCtx, p, nil,
DistributionTypeSystemTenantOnly)
DistributionTypeAlways)
planCtx.stmtType = recv.stmtType

execCfg.DistSQLPlanner.PlanAndRun(
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/distsql_spec_exec_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func newDistSQLSpecExecFactory(
}
distribute := DistributionType(DistributionTypeNone)
if e.planningMode != distSQLLocalOnlyPlanning {
distribute = DistributionTypeSystemTenantOnly
distribute = DistributionTypeAlways
}
evalCtx := p.ExtendedEvalContext()
e.planCtx = e.dsp.NewPlanningCtx(ctx, evalCtx, e.planner, e.planner.txn, distribute)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/index_backfiller.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (ib *IndexBackfillPlanner) plan(
sd := NewInternalSessionData(ctx, ib.execCfg.Settings, "plan-index-backfill")
evalCtx = createSchemaChangeEvalCtx(ctx, ib.execCfg, sd, nowTimestamp, descriptors)
planCtx = ib.execCfg.DistSQLPlanner.NewPlanningCtx(ctx, &evalCtx,
nil /* planner */, txn.KV(), DistributionTypeSystemTenantOnly)
nil /* planner */, txn.KV(), DistributionTypeAlways)
// TODO(ajwerner): Adopt util.ConstantWithMetamorphicTestRange for the
// batch size. Also plumb in a testing knob.
chunkSize := indexBackfillBatchSize.Get(&ib.execCfg.Settings.SV)
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/mvcc_backfiller.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (im *IndexBackfillerMergePlanner) plan(
sd := NewInternalSessionData(ctx, im.execCfg.Settings, "plan-index-backfill-merge")
evalCtx = createSchemaChangeEvalCtx(ctx, im.execCfg, sd, txn.KV().ReadTimestamp(), descriptors)
planCtx = im.execCfg.DistSQLPlanner.NewPlanningCtx(ctx, &evalCtx, nil /* planner */, txn.KV(),
DistributionTypeSystemTenantOnly)
DistributionTypeAlways)

spec, err := initIndexBackfillMergerSpec(*tableDesc.TableDesc(), addedIndexes, temporaryIndexes, mergeTimestamp)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (dsp *DistSQLPlanner) Exec(

distributionType := DistributionType(DistributionTypeNone)
if distribute {
distributionType = DistributionTypeSystemTenantOnly
distributionType = DistributionTypeAlways
}
evalCtx := p.ExtendedEvalContext()
planCtx := execCfg.DistSQLPlanner.NewPlanningCtx(ctx, evalCtx, p, p.txn,
Expand Down

0 comments on commit be112f2

Please sign in to comment.