Skip to content

Commit

Permalink
Merge pull request #109441 from knz/backport23.1-109419
Browse files Browse the repository at this point in the history
  • Loading branch information
knz authored Aug 24, 2023
2 parents 95a2d41 + cec7f34 commit ad2dcb4
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 46 deletions.
4 changes: 3 additions & 1 deletion pkg/ccl/changefeedccl/changefeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3534,7 +3534,9 @@ func TestChangefeedWorksOnRBRChange(t *testing.T) {
//
// error executing 'ALTER DATABASE d PRIMARY REGION
// "us-east-1"': pq: get_live_cluster_regions: unimplemented:
// operation is unsupported in multi-tenancy mode
// operation is unsupported inside virtual clusters
//
// TODO(knz): This seems incorrect; see issue #109418.
opts := []feedTestOption{
feedTestNoTenants,
feedTestEnterpriseSinks,
Expand Down
7 changes: 4 additions & 3 deletions pkg/ccl/changefeedccl/nemeses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ func TestChangefeedNemeses(t *testing.T) {
}

// Tenant tests disabled because ALTER TABLE .. SPLIT is not
// support in multi-tenancy mode:
// supported with cluster virtualization:
//
// nemeses_test.go:39: pq: unimplemented: operation is
// unsupported in multi-tenancy mode
// nemeses_test.go:39: pq: unimplemented: operation is unsupported inside virtual clusters
//
// TODO(knz): This seems incorrect, see issue #109417.
cdcTest(t, testFn, feedTestNoTenants)
log.Flush()
entries, err := log.FetchEntriesFromFiles(0, math.MaxInt64, 1,
Expand Down
10 changes: 6 additions & 4 deletions pkg/ccl/changefeedccl/validations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ func TestCatchupScanOrdering(t *testing.T) {
}
})
}
// Tenant tests skipped because of:
// validations_test.go:40: executing ALTER TABLE bank SPLIT AT
// VALUES (5): pq: unimplemented: operation is unsupported in
// multi-tenancy mode
// Tenant tests disabled because ALTER TABLE .. SPLIT is not
// supported with cluster virtualization:
//
// nemeses_test.go:39: pq: unimplemented: operation is unsupported inside virtual clusters
//
// TODO(knz): This seems incorrect, see issue #109417.
cdcTest(t, testFn, feedTestNoTenants)
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant
Original file line number Diff line number Diff line change
Expand Up @@ -414,17 +414,17 @@ node_id component field value
0 UI Port <port>
0 UI URI /

statement error unsupported in multi-tenancy mode
statement error unsupported within a virtual cluster
SELECT node_id, network, regexp_replace(address, '\d+$', '<port>') as address, attrs, locality, regexp_replace(server_version, '^\d+\.\d+(-\d+)?$', '<server_version>') as server_version FROM crdb_internal.gossip_nodes WHERE node_id = 1

statement error unsupported in multi-tenancy mode
statement error unsupported within a virtual cluster
SELECT node_id, epoch, regexp_replace(expiration, '^\d+\.\d+,\d+$', '<timestamp>') as expiration, draining, decommissioning, membership FROM crdb_internal.gossip_liveness WHERE node_id = 1

statement error unsupported in multi-tenancy mode
statement error unsupported within a virtual cluster
SELECT node_id, network, regexp_replace(address, '\d+$', '<port>') as address, attrs, locality, regexp_replace(server_version, '^\d+\.\d+(-\d+)?$', '<server_version>') as server_version, regexp_replace(go_version, '^go.+$', '<go_version>') as go_version
FROM crdb_internal.kv_node_status WHERE node_id = 1

statement error unsupported in multi-tenancy mode
statement error unsupported within a virtual cluster
SELECT node_id, store_id, attrs, used
FROM crdb_internal.kv_store_status WHERE node_id = 1

Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/logictestccl/testdata/logic_test/tenant_unsupported
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ CREATE TEMP TABLE users (id UUID, city STRING, CONSTRAINT "primary" PRIMARY KEY

# Cannot read store or node status

statement error operation is unsupported in multi-tenancy mode
statement error operation is unsupported within a virtual cluster
SELECT * FROM crdb_internal.kv_store_status

statement error operation is unsupported in multi-tenancy mode
statement error operation is unsupported within a virtual cluster
SELECT * FROM crdb_internal.kv_node_status
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Note that we haven't used the setting override directive in this file to
# override the default.

statement error pq: unimplemented: operation is unsupported in multi-tenancy mode
statement error pq: unimplemented: operation is unsupported within a virtual cluster
ALTER TABLE t CONFIGURE ZONE USING num_replicas = 5;

statement error setting sql.zone_configs.allow_for_secondary_tenant.enabled is only settable by the operator
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/workloadccl/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func getNodeCount(ctx context.Context, sqlDB *gosql.DB) (int, error) {
if err := sqlDB.QueryRow(numNodesQuery).Scan(&numNodes); err != nil {
// If the query is unsupported because we're in
// multi-tenant mode, use the sql_instances table.
if !strings.Contains(err.Error(), errorutil.UnsupportedWithMultiTenancyMessage) {
if !strings.Contains(err.Error(), errorutil.UnsupportedUnderClusterVirtualizationMessage) {
return 0, err

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ end_test
start_test "Expect an error if geo-partitioning is requested with multitenant mode"
send "$argv demo --no-line-editor --geo-partitioned-replicas --log-dir=logs \r"
# expect a failure
eexpect "operation is unsupported in multi-tenancy mode"
eexpect "operation is unsupported within a virtual cluster"
eexpect $prompt
end_test

Expand Down
12 changes: 6 additions & 6 deletions pkg/cli/testdata/zip/testzip_shared_process_tenant
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/cluster/test-tenant/crdb_internal.invalid_objects.txt... done
[cluster] retrieving SQL data for crdb_internal.jobs... writing output: debug/cluster/test-tenant/crdb_internal.jobs.txt... done
[cluster] retrieving SQL data for crdb_internal.kv_node_liveness... writing output: debug/cluster/test-tenant/crdb_internal.kv_node_liveness.txt...
[cluster] retrieving SQL data for crdb_internal.kv_node_liveness: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_node_liveness: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_node_liveness: creating error output: debug/cluster/test-tenant/crdb_internal.kv_node_liveness.txt.err.txt... done
[cluster] retrieving SQL data for crdb_internal.kv_node_status... writing output: debug/cluster/test-tenant/crdb_internal.kv_node_status.txt...
[cluster] retrieving SQL data for crdb_internal.kv_node_status: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_node_status: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_node_status: creating error output: debug/cluster/test-tenant/crdb_internal.kv_node_status.txt.err.txt... done
[cluster] retrieving SQL data for crdb_internal.kv_store_status... writing output: debug/cluster/test-tenant/crdb_internal.kv_store_status.txt...
[cluster] retrieving SQL data for crdb_internal.kv_store_status: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_store_status: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_store_status: creating error output: debug/cluster/test-tenant/crdb_internal.kv_store_status.txt.err.txt... done
[cluster] retrieving SQL data for crdb_internal.kv_system_privileges... writing output: debug/cluster/test-tenant/crdb_internal.kv_system_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.partitions... writing output: debug/cluster/test-tenant/crdb_internal.partitions.txt... done
Expand Down Expand Up @@ -227,13 +227,13 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[node 1] retrieving SQL data for crdb_internal.active_range_feeds... writing output: debug/cluster/test-tenant/nodes/1/crdb_internal.active_range_feeds.txt... done
[node 1] retrieving SQL data for crdb_internal.feature_usage... writing output: debug/cluster/test-tenant/nodes/1/crdb_internal.feature_usage.txt... done
[node 1] retrieving SQL data for crdb_internal.gossip_alerts... writing output: debug/cluster/test-tenant/nodes/1/crdb_internal.gossip_alerts.txt...
[node 1] retrieving SQL data for crdb_internal.gossip_alerts: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_alerts: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_alerts: creating error output: debug/cluster/test-tenant/nodes/1/crdb_internal.gossip_alerts.txt.err.txt... done
[node 1] retrieving SQL data for crdb_internal.gossip_liveness... writing output: debug/cluster/test-tenant/nodes/1/crdb_internal.gossip_liveness.txt...
[node 1] retrieving SQL data for crdb_internal.gossip_liveness: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_liveness: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_liveness: creating error output: debug/cluster/test-tenant/nodes/1/crdb_internal.gossip_liveness.txt.err.txt... done
[node 1] retrieving SQL data for crdb_internal.gossip_nodes... writing output: debug/cluster/test-tenant/nodes/1/crdb_internal.gossip_nodes.txt...
[node 1] retrieving SQL data for crdb_internal.gossip_nodes: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_nodes: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_nodes: creating error output: debug/cluster/test-tenant/nodes/1/crdb_internal.gossip_nodes.txt.err.txt... done
[node 1] retrieving SQL data for crdb_internal.leases... writing output: debug/cluster/test-tenant/nodes/1/crdb_internal.leases.txt... done
[node 1] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/cluster/test-tenant/nodes/1/crdb_internal.node_build_info.txt... done
Expand Down
12 changes: 6 additions & 6 deletions pkg/cli/testdata/zip/testzip_tenant_separate_process
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
[cluster] retrieving SQL data for crdb_internal.jobs... writing output: debug/crdb_internal.jobs.txt... done
[cluster] retrieving SQL data for crdb_internal.kv_node_liveness... writing output: debug/crdb_internal.kv_node_liveness.txt...
[cluster] retrieving SQL data for crdb_internal.kv_node_liveness: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_node_liveness: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_node_liveness: creating error output: debug/crdb_internal.kv_node_liveness.txt.err.txt... done
[cluster] retrieving SQL data for crdb_internal.kv_node_status... writing output: debug/crdb_internal.kv_node_status.txt...
[cluster] retrieving SQL data for crdb_internal.kv_node_status: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_node_status: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_node_status: creating error output: debug/crdb_internal.kv_node_status.txt.err.txt... done
[cluster] retrieving SQL data for crdb_internal.kv_store_status... writing output: debug/crdb_internal.kv_store_status.txt...
[cluster] retrieving SQL data for crdb_internal.kv_store_status: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_store_status: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[cluster] retrieving SQL data for crdb_internal.kv_store_status: creating error output: debug/crdb_internal.kv_store_status.txt.err.txt... done
[cluster] retrieving SQL data for crdb_internal.kv_system_privileges... writing output: debug/crdb_internal.kv_system_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.partitions... writing output: debug/crdb_internal.partitions.txt... done
Expand Down Expand Up @@ -108,13 +108,13 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[node 1] retrieving SQL data for crdb_internal.active_range_feeds... writing output: debug/nodes/1/crdb_internal.active_range_feeds.txt... done
[node 1] retrieving SQL data for crdb_internal.feature_usage... writing output: debug/nodes/1/crdb_internal.feature_usage.txt... done
[node 1] retrieving SQL data for crdb_internal.gossip_alerts... writing output: debug/nodes/1/crdb_internal.gossip_alerts.txt...
[node 1] retrieving SQL data for crdb_internal.gossip_alerts: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_alerts: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_alerts: creating error output: debug/nodes/1/crdb_internal.gossip_alerts.txt.err.txt... done
[node 1] retrieving SQL data for crdb_internal.gossip_liveness... writing output: debug/nodes/1/crdb_internal.gossip_liveness.txt...
[node 1] retrieving SQL data for crdb_internal.gossip_liveness: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_liveness: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_liveness: creating error output: debug/nodes/1/crdb_internal.gossip_liveness.txt.err.txt... done
[node 1] retrieving SQL data for crdb_internal.gossip_nodes... writing output: debug/nodes/1/crdb_internal.gossip_nodes.txt...
[node 1] retrieving SQL data for crdb_internal.gossip_nodes: last request failed: ERROR: unimplemented: operation is unsupported in multi-tenancy mode (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_nodes: last request failed: ERROR: unimplemented: operation is unsupported within a virtual cluster (SQLSTATE 0A000)
[node 1] retrieving SQL data for crdb_internal.gossip_nodes: creating error output: debug/nodes/1/crdb_internal.gossip_nodes.txt.err.txt... done
[node 1] retrieving SQL data for crdb_internal.leases... writing output: debug/nodes/1/crdb_internal.leases.txt... done
[node 1] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/nodes/1/crdb_internal.node_build_info.txt... done
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/kvserverbase/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ var _ StoresIterator = UnsupportedStoresIterator{}

// ForEachStore is part of the StoresIterator interface.
func (i UnsupportedStoresIterator) ForEachStore(f func(Store) error) error {
return errorutil.UnsupportedWithMultiTenancy(errorutil.FeatureNotAvailableToNonSystemTenantsIssue)
return errorutil.UnsupportedUnderClusterVirtualization(errorutil.FeatureNotAvailableToNonSystemTenantsIssue)
}
2 changes: 1 addition & 1 deletion pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ type SQLServer struct {
//
// TODO(tbg): give all of these fields a wrapper that can signal whether the
// respective object is available. When it is not, return
// UnsupportedWithMultiTenancy.
// UnsupportedUnderClusterVirtualization.
type sqlServerOptionalKVArgs struct {
// nodesStatusServer gives access to the NodesStatus service.
nodesStatusServer serverpb.OptionalNodesStatusServer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LogicTest: 3node-tenant

query error pq: crdb_internal.kv_set_queue_active\(\): unimplemented: operation is unsupported in multi-tenancy mode
query error pq: crdb_internal.kv_set_queue_active\(\): unimplemented: operation is unsupported within a virtual cluster
select crdb_internal.kv_set_queue_active('split', true);

query error pq: crdb_internal.kv_enqueue_replica\(\): unimplemented: operation is unsupported in multi-tenancy mode
query error pq: crdb_internal.kv_enqueue_replica\(\): unimplemented: operation is unsupported within a virtual cluster
select crdb_internal.kv_enqueue_replica(42, 'split', true);
2 changes: 1 addition & 1 deletion pkg/sql/set_zone_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (p *planner) SetZoneConfig(ctx context.Context, n *tree.SetZoneConfig) (pla
// Return an unimplemented error here instead of referencing the cluster
// setting here as zone configurations for secondary tenants are intended to
// be hidden.
return nil, errorutil.UnsupportedWithMultiTenancy(MultitenancyZoneCfgIssueNo)
return nil, errorutil.UnsupportedUnderClusterVirtualization(MultitenancyZoneCfgIssueNo)
}

if err := checkPrivilegeForSetZoneConfig(ctx, p, n.ZoneSpecifier); err != nil {
Expand Down
16 changes: 8 additions & 8 deletions pkg/util/errorutil/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ package errorutil

import "github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented"

// UnsupportedWithMultiTenancyMessage is the message used by UnsupportedWithMultiTenancy error.
const UnsupportedWithMultiTenancyMessage = "operation is unsupported in multi-tenancy mode"
// UnsupportedUnderClusterVirtualizationMessage is the message used by UnsupportedUnderClusterVirtualization error.
const UnsupportedUnderClusterVirtualizationMessage = "operation is unsupported within a virtual cluster"

// UnsupportedWithMultiTenancy returns an error suitable for returning when an
// operation could not be carried out due to the SQL server running in
// multi-tenancy mode. In that mode, Gossip and other components of the KV layer
// are not available.
func UnsupportedWithMultiTenancy(issue int) error {
return unimplemented.NewWithIssue(issue, UnsupportedWithMultiTenancyMessage)
// UnsupportedUnderClusterVirtualization returns an error suitable for
// returning when an operation could not be carried out due to the SQL
// server running inside a virtual cluster. In that mode, Gossip and
// other components of the KV layer are not available.
func UnsupportedUnderClusterVirtualization(issue int) error {
return unimplemented.NewWithIssue(issue, UnsupportedUnderClusterVirtualizationMessage)
}

// FeatureNotAvailableToNonSystemTenantsIssue is to be used with the
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/errorutil/tenant_deprecated_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (w TenantSQLDeprecatedWrapper) Optional() (interface{}, bool) {
func (w TenantSQLDeprecatedWrapper) OptionalErr(issue int) (interface{}, error) {
v, ok := w.Optional()
if !ok {
return nil, UnsupportedWithMultiTenancy(issue)
return nil, UnsupportedUnderClusterVirtualization(issue)
}
return v, nil
}
9 changes: 6 additions & 3 deletions pkg/workload/workloadsql/workloadsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func Split(ctx context.Context, db *gosql.DB, table workload.Table, concurrency
_, err := db.Exec("SHOW RANGES FROM TABLE system.descriptor")
if err != nil {
if strings.Contains(err.Error(), "not fully contained in tenant") ||
strings.Contains(err.Error(), errorutil.UnsupportedWithMultiTenancyMessage) {
strings.Contains(err.Error(), errorutil.UnsupportedUnderClusterVirtualizationMessage) {
log.Infof(ctx, `skipping workload splits; can't split on tenants'`)
//nolint:returnerrcheck
return nil
Expand Down Expand Up @@ -171,9 +171,12 @@ func Split(ctx context.Context, db *gosql.DB, table workload.Table, concurrency
// not) help you.
stmt := buf.String()
if _, err := db.Exec(stmt); err != nil {
if strings.Contains(err.Error(), errorutil.UnsupportedWithMultiTenancyMessage) {
if strings.Contains(err.Error(), errorutil.UnsupportedUnderClusterVirtualizationMessage) {
// We don't care about split errors if we're running a workload
// in multi-tenancy mode; we can't do them so we'll just continue
// with virtual clusters; we can't do them so we'll just continue.
//
// TODO(knz): This seems incorrect: this should be possible
// with the right capability. See: #109422.
break
}
return errors.Wrapf(err, "executing %s", stmt)
Expand Down

0 comments on commit ad2dcb4

Please sign in to comment.