diff --git a/pkg/ccl/multiregionccl/testdata/secondary_region b/pkg/ccl/multiregionccl/testdata/secondary_region index 16a3c9fc94da..9fb454dab0cb 100644 --- a/pkg/ccl/multiregionccl/testdata/secondary_region +++ b/pkg/ccl/multiregionccl/testdata/secondary_region @@ -1,6 +1,3 @@ -skip issue-num=98020 ----- - new-cluster localities=us-east-1,us-east-1,us-west-1,us-west-1,us-central-1,us-central-1,us-central-1,eu-west-1,eu-west-1,eu-west-1 ---- diff --git a/pkg/sql/executor_statement_metrics.go b/pkg/sql/executor_statement_metrics.go index 496ccf132f19..47008287c2a4 100644 --- a/pkg/sql/executor_statement_metrics.go +++ b/pkg/sql/executor_statement_metrics.go @@ -12,9 +12,7 @@ package sql import ( "context" - "sort" "strconv" - "sync" "github.com/cockroachdb/cockroach/pkg/sql/appstatspb" "github.com/cockroachdb/cockroach/pkg/sql/contentionpb" @@ -22,7 +20,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/idxrecommendations" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sessionphase" - "github.com/cockroachdb/cockroach/pkg/sql/sqlinstance" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/cockroach/pkg/util/log" @@ -189,7 +186,11 @@ func (ex *connExecutor) recordStatementSummary( } nodes := util.CombineUnique(getNodesFromPlanner(planner), []int64{nodeID}) - regions := getRegionsForNodes(ctx, nodes, planner.DistSQLPlanner().sqlAddressResolver) + + regions := []string{} + if region, ok := ex.server.cfg.Locality.Find("region"); ok { + regions = append(regions, region) + } recordedStmtStats := sqlstats.RecordedStmtStats{ SessionID: ex.sessionID, @@ -327,49 +328,3 @@ func getNodesFromPlanner(planner *planner) []int64 { } return nodes } - -var regionsPool = sync.Pool{ - New: func() interface{} { - return make(map[string]struct{}) - }, -} - -func getRegionsForNodes( - ctx context.Context, nodeIDs []int64, resolver sqlinstance.AddressResolver, -) []string { - if resolver == nil { - return nil - } - - instances, err := resolver.GetAllInstances(ctx) - if err != nil { - return nil - } - - regions := regionsPool.Get().(map[string]struct{}) - defer func() { - for region := range regions { - delete(regions, region) - } - regionsPool.Put(regions) - }() - - for _, instance := range instances { - for _, node := range nodeIDs { - // TODO(todd): Using int64 for nodeIDs was inappropriate, see #95088. - if int32(instance.InstanceID) == int32(node) { - if region, ok := instance.Locality.Find("region"); ok { - regions[region] = struct{}{} - } - break - } - } - } - - result := make([]string, 0, len(regions)) - for region := range regions { - result = append(result, region) - } - sort.Strings(result) - return result -}