From 149e19ff6702cf60ebaeaf6bddb1d52a4389adeb Mon Sep 17 00:00:00 2001 From: irfan sharif Date: Fri, 11 Jun 2021 23:03:09 -0400 Subject: [PATCH] sql: add `system.span_configurations` for kv span configs Part of #67679. It's not wired up to anything yet; we'll later use this system-tenant only table to store KV span configs. Release note (sql change): We've added a `system.span_configurations` table. This will later be used to store authoritative span configs that KV has decided to apply. --- .../settings/settings-for-tenants.txt | 2 +- docs/generated/settings/settings.html | 2 +- pkg/ccl/backupccl/system_schema.go | 3 + pkg/cli/testdata/doctor/test_examine_cluster | 2 +- pkg/cli/testdata/zip/partial1 | 6 +- pkg/cli/testdata/zip/partial1_excluded | 6 +- pkg/cli/testdata/zip/partial2 | 6 +- pkg/cli/testdata/zip/testzip | 3 +- pkg/cli/testdata/zip/testzip_concurrent | 18 ++- pkg/clusterversion/cockroach_versions.go | 7 ++ pkg/clusterversion/key_string.go | 6 +- pkg/keys/constants.go | 1 + pkg/migration/migrations/BUILD.bazel | 1 + pkg/migration/migrations/migrations.go | 6 + .../migrations/span_configurations.go | 32 +++++ pkg/spanconfig/spanconfigmanager/BUILD.bazel | 1 - pkg/sql/catalog/bootstrap/metadata.go | 2 +- pkg/sql/catalog/descpb/privilege.go | 1 + pkg/sql/catalog/systemschema/system.go | 39 ++++++ .../logictest/testdata/logic_test/grant_table | 35 ++++-- .../testdata/logic_test/information_schema | 32 ++++- .../logictest/testdata/logic_test/pg_catalog | 2 + pkg/sql/logictest/testdata/logic_test/ranges | 6 +- .../logictest/testdata/logic_test/show_source | 6 +- pkg/sql/logictest/testdata/logic_test/system | 12 ++ .../testdata/logic_test/system_namespace | 1 + .../testdata/autocommit_nonmetamorphic | 118 +++++++++--------- pkg/sql/opt/exec/execbuilder/testdata/delete | 6 +- .../testdata/show_trace_nonmetamorphic | 24 ++-- pkg/sql/pgwire/pgwire_test.go | 2 +- pkg/sql/tests/system_table_test.go | 1 + pkg/sql/tests/testdata/initial_keys | 7 +- 32 files changed, 287 insertions(+), 109 deletions(-) create mode 100644 pkg/migration/migrations/span_configurations.go diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt index 27d10f83bbd1..7ba06b7bc548 100644 --- a/docs/generated/settings/settings-for-tenants.txt +++ b/docs/generated/settings/settings-for-tenants.txt @@ -152,4 +152,4 @@ trace.datadog.project string CockroachDB the project under which traces will be trace.debug.enable boolean false if set, traces for recent requests can be seen at https:///debug/requests trace.lightstep.token string if set, traces go to Lightstep using this token trace.zipkin.collector string if set, traces go to the given Zipkin instance (example: '127.0.0.1:9411'). Only one tracer can be configured at a time. -version version 21.1-134 set the active cluster version in the format '.' +version version 21.1-136 set the active cluster version in the format '.' diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index 80eb5d416e9d..5a99ec89e8af 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -156,6 +156,6 @@ trace.debug.enablebooleanfalseif set, traces for recent requests can be seen at https:///debug/requests trace.lightstep.tokenstringif set, traces go to Lightstep using this token trace.zipkin.collectorstringif set, traces go to the given Zipkin instance (example: '127.0.0.1:9411'). Only one tracer can be configured at a time. -versionversion21.1-134set the active cluster version in the format '.' +versionversion21.1-136set the active cluster version in the format '.' diff --git a/pkg/ccl/backupccl/system_schema.go b/pkg/ccl/backupccl/system_schema.go index e552ff40ef1e..dd887ac46012 100644 --- a/pkg/ccl/backupccl/system_schema.go +++ b/pkg/ccl/backupccl/system_schema.go @@ -352,6 +352,9 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{ systemschema.SQLInstancesTable.GetName(): { shouldIncludeInClusterBackup: optOutOfClusterBackup, }, + systemschema.SpanConfigurationsTable.GetName(): { + shouldIncludeInClusterBackup: optOutOfClusterBackup, + }, } // GetSystemTablesToIncludeInClusterBackup returns a set of system table names that diff --git a/pkg/cli/testdata/doctor/test_examine_cluster b/pkg/cli/testdata/doctor/test_examine_cluster index 24d84a13b232..1c2777f765b6 100644 --- a/pkg/cli/testdata/doctor/test_examine_cluster +++ b/pkg/cli/testdata/doctor/test_examine_cluster @@ -1,7 +1,7 @@ debug doctor examine cluster ---- debug doctor examine cluster -Examining 40 descriptors and 41 namespace entries... +Examining 41 descriptors and 42 namespace entries... ParentID 50, ParentSchemaID 29: relation "foo" (53): expected matching namespace entry, found none Examining 4 jobs... ERROR: validation failed diff --git a/pkg/cli/testdata/zip/partial1 b/pkg/cli/testdata/zip/partial1 index b121ebfd484c..fdae3d0fc1eb 100644 --- a/pkg/cli/testdata/zip/partial1 +++ b/pkg/cli/testdata/zip/partial1 @@ -70,7 +70,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 1] 1 log file ... [node 1] [log file ... [node 1] requesting ranges... received response... done -[node 1] 42 ranges found +[node 1] 43 ranges found [node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done [node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done [node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done @@ -113,6 +113,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 1] writing range 40... converting to JSON... writing binary output: debug/nodes/1/ranges/40.json... done [node 1] writing range 41... converting to JSON... writing binary output: debug/nodes/1/ranges/41.json... done [node 1] writing range 42... converting to JSON... writing binary output: debug/nodes/1/ranges/42.json... done +[node 1] writing range 43... converting to JSON... writing binary output: debug/nodes/1/ranges/43.json... done [node 2] node status... converting to JSON... writing binary output: debug/nodes/2/status.json... done [node 2] using SQL connection URL: postgresql://... [node 2] retrieving SQL data for crdb_internal.feature_usage... writing output: debug/nodes/2/crdb_internal.feature_usage.txt... @@ -231,7 +232,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 3] 1 log file ... [node 3] [log file ... [node 3] requesting ranges... received response... done -[node 3] 42 ranges found +[node 3] 43 ranges found [node 3] writing range 1... converting to JSON... writing binary output: debug/nodes/3/ranges/1.json... done [node 3] writing range 2... converting to JSON... writing binary output: debug/nodes/3/ranges/2.json... done [node 3] writing range 3... converting to JSON... writing binary output: debug/nodes/3/ranges/3.json... done @@ -274,5 +275,6 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 3] writing range 40... converting to JSON... writing binary output: debug/nodes/3/ranges/40.json... done [node 3] writing range 41... converting to JSON... writing binary output: debug/nodes/3/ranges/41.json... done [node 3] writing range 42... converting to JSON... writing binary output: debug/nodes/3/ranges/42.json... done +[node 3] writing range 43... converting to JSON... writing binary output: debug/nodes/3/ranges/43.json... done [cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done [cluster] hot range summary script... writing binary output: debug/hot-ranges.sh... done diff --git a/pkg/cli/testdata/zip/partial1_excluded b/pkg/cli/testdata/zip/partial1_excluded index dbe7d896619e..0708fe92e0d4 100644 --- a/pkg/cli/testdata/zip/partial1_excluded +++ b/pkg/cli/testdata/zip/partial1_excluded @@ -70,7 +70,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 1] 1 log file ... [node 1] [log file ... [node 1] requesting ranges... received response... done -[node 1] 42 ranges found +[node 1] 43 ranges found [node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done [node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done [node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done @@ -113,6 +113,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 1] writing range 40... converting to JSON... writing binary output: debug/nodes/1/ranges/40.json... done [node 1] writing range 41... converting to JSON... writing binary output: debug/nodes/1/ranges/41.json... done [node 1] writing range 42... converting to JSON... writing binary output: debug/nodes/1/ranges/42.json... done +[node 1] writing range 43... converting to JSON... writing binary output: debug/nodes/1/ranges/43.json... done [node 2] skipping node... writing binary output: debug/nodes/2.skipped... done [node 3] node status... converting to JSON... writing binary output: debug/nodes/3/status.json... done [node 3] using SQL connection URL: postgresql://... @@ -149,7 +150,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 3] 1 log file ... [node 3] [log file ... [node 3] requesting ranges... received response... done -[node 3] 42 ranges found +[node 3] 43 ranges found [node 3] writing range 1... converting to JSON... writing binary output: debug/nodes/3/ranges/1.json... done [node 3] writing range 2... converting to JSON... writing binary output: debug/nodes/3/ranges/2.json... done [node 3] writing range 3... converting to JSON... writing binary output: debug/nodes/3/ranges/3.json... done @@ -192,5 +193,6 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 3] writing range 40... converting to JSON... writing binary output: debug/nodes/3/ranges/40.json... done [node 3] writing range 41... converting to JSON... writing binary output: debug/nodes/3/ranges/41.json... done [node 3] writing range 42... converting to JSON... writing binary output: debug/nodes/3/ranges/42.json... done +[node 3] writing range 43... converting to JSON... writing binary output: debug/nodes/3/ranges/43.json... done [cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done [cluster] hot range summary script... writing binary output: debug/hot-ranges.sh... done diff --git a/pkg/cli/testdata/zip/partial2 b/pkg/cli/testdata/zip/partial2 index c0807332419d..db67bb1943e9 100644 --- a/pkg/cli/testdata/zip/partial2 +++ b/pkg/cli/testdata/zip/partial2 @@ -70,7 +70,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 1] 1 log file ... [node 1] [log file ... [node 1] requesting ranges... received response... done -[node 1] 42 ranges found +[node 1] 43 ranges found [node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done [node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done [node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done @@ -113,6 +113,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 1] writing range 40... converting to JSON... writing binary output: debug/nodes/1/ranges/40.json... done [node 1] writing range 41... converting to JSON... writing binary output: debug/nodes/1/ranges/41.json... done [node 1] writing range 42... converting to JSON... writing binary output: debug/nodes/1/ranges/42.json... done +[node 1] writing range 43... converting to JSON... writing binary output: debug/nodes/1/ranges/43.json... done [node 3] node status... converting to JSON... writing binary output: debug/nodes/3/status.json... done [node 3] using SQL connection URL: postgresql://... [node 3] retrieving SQL data for crdb_internal.feature_usage... writing output: debug/nodes/3/crdb_internal.feature_usage.txt... done @@ -148,7 +149,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 3] 1 log file ... [node 3] [log file ... [node 3] requesting ranges... received response... done -[node 3] 42 ranges found +[node 3] 43 ranges found [node 3] writing range 1... converting to JSON... writing binary output: debug/nodes/3/ranges/1.json... done [node 3] writing range 2... converting to JSON... writing binary output: debug/nodes/3/ranges/2.json... done [node 3] writing range 3... converting to JSON... writing binary output: debug/nodes/3/ranges/3.json... done @@ -191,5 +192,6 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 3] writing range 40... converting to JSON... writing binary output: debug/nodes/3/ranges/40.json... done [node 3] writing range 41... converting to JSON... writing binary output: debug/nodes/3/ranges/41.json... done [node 3] writing range 42... converting to JSON... writing binary output: debug/nodes/3/ranges/42.json... done +[node 3] writing range 43... converting to JSON... writing binary output: debug/nodes/3/ranges/43.json... done [cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done [cluster] hot range summary script... writing binary output: debug/hot-ranges.sh... done diff --git a/pkg/cli/testdata/zip/testzip b/pkg/cli/testdata/zip/testzip index d18653d7c5e0..f23137583008 100644 --- a/pkg/cli/testdata/zip/testzip +++ b/pkg/cli/testdata/zip/testzip @@ -70,7 +70,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null [node 1] requesting log file ... [node 1] 0 log file ... [node 1] requesting ranges... received response... done -[node 1] 42 ranges found +[node 1] 43 ranges found [node 1] writing range 1... converting to JSON... writing binary output: debug/nodes/1/ranges/1.json... done [node 1] writing range 2... converting to JSON... writing binary output: debug/nodes/1/ranges/2.json... done [node 1] writing range 3... converting to JSON... writing binary output: debug/nodes/1/ranges/3.json... done @@ -113,5 +113,6 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null [node 1] writing range 40... converting to JSON... writing binary output: debug/nodes/1/ranges/40.json... done [node 1] writing range 41... converting to JSON... writing binary output: debug/nodes/1/ranges/41.json... done [node 1] writing range 42... converting to JSON... writing binary output: debug/nodes/1/ranges/42.json... done +[node 1] writing range 43... converting to JSON... writing binary output: debug/nodes/1/ranges/43.json... done [cluster] pprof summary script... writing binary output: debug/pprof-summary.sh... done [cluster] hot range summary script... writing binary output: debug/hot-ranges.sh... done diff --git a/pkg/cli/testdata/zip/testzip_concurrent b/pkg/cli/testdata/zip/testzip_concurrent index 7f71695b740f..eebf665527d9 100644 --- a/pkg/cli/testdata/zip/testzip_concurrent +++ b/pkg/cli/testdata/zip/testzip_concurrent @@ -118,7 +118,7 @@ zip [cluster] using SQL address: ... [cluster] using SQL address: ... [node 1] 1 log file ... -[node 1] 42 ranges found +[node 1] 43 ranges found [node 1] [log file ... [node 1] [log file ... [node 1] [log file ... @@ -366,6 +366,10 @@ zip [node 1] writing range 42: converting to JSON... [node 1] writing range 42: done [node 1] writing range 42: writing binary output: debug/nodes/1/ranges/42.json... +[node 1] writing range 43... +[node 1] writing range 43: converting to JSON... +[node 1] writing range 43: done +[node 1] writing range 43: writing binary output: debug/nodes/1/ranges/43.json... [node 1] writing range 4: converting to JSON... [node 1] writing range 4: done [node 1] writing range 4: writing binary output: debug/nodes/1/ranges/4.json... @@ -390,7 +394,7 @@ zip [node 1] writing range 9: done [node 1] writing range 9: writing binary output: debug/nodes/1/ranges/9.json... [node 2] 1 log file ... -[node 2] 42 ranges found +[node 2] 43 ranges found [node 2] [log file ... [node 2] [log file ... [node 2] [log file ... @@ -638,6 +642,10 @@ zip [node 2] writing range 42: converting to JSON... [node 2] writing range 42: done [node 2] writing range 42: writing binary output: debug/nodes/2/ranges/42.json... +[node 2] writing range 43... +[node 2] writing range 43: converting to JSON... +[node 2] writing range 43: done +[node 2] writing range 43: writing binary output: debug/nodes/2/ranges/43.json... [node 2] writing range 4: converting to JSON... [node 2] writing range 4: done [node 2] writing range 4: writing binary output: debug/nodes/2/ranges/4.json... @@ -662,7 +670,7 @@ zip [node 2] writing range 9: done [node 2] writing range 9: writing binary output: debug/nodes/2/ranges/9.json... [node 3] 1 log file ... -[node 3] 42 ranges found +[node 3] 43 ranges found [node 3] [log file ... [node 3] [log file ... [node 3] [log file ... @@ -910,6 +918,10 @@ zip [node 3] writing range 42: converting to JSON... [node 3] writing range 42: done [node 3] writing range 42: writing binary output: debug/nodes/3/ranges/42.json... +[node 3] writing range 43... +[node 3] writing range 43: converting to JSON... +[node 3] writing range 43: done +[node 3] writing range 43: writing binary output: debug/nodes/3/ranges/43.json... [node 3] writing range 4: converting to JSON... [node 3] writing range 4: done [node 3] writing range 4: writing binary output: debug/nodes/3/ranges/4.json... diff --git a/pkg/clusterversion/cockroach_versions.go b/pkg/clusterversion/cockroach_versions.go index 6364a5559469..7c8b46b26e91 100644 --- a/pkg/clusterversion/cockroach_versions.go +++ b/pkg/clusterversion/cockroach_versions.go @@ -285,6 +285,9 @@ const ( // AutoSpanConfigReconciliationJob adds the AutoSpanConfigReconciliationJob // type. AutoSpanConfigReconciliationJob + // SpanConfigurationsTable adds the span configurations system table, to + // store all KV span configs. + SpanConfigurationsTable // Step (1): Add new versions here. ) @@ -474,6 +477,10 @@ var versionsSingleton = keyedVersions{ Key: AutoSpanConfigReconciliationJob, Version: roachpb.Version{Major: 21, Minor: 1, Internal: 134}, }, + { + Key: SpanConfigurationsTable, + Version: roachpb.Version{Major: 21, Minor: 1, Internal: 136}, + }, // Step (2): Add new versions here. } diff --git a/pkg/clusterversion/key_string.go b/pkg/clusterversion/key_string.go index e4e41a461e62..d31628cd1c1f 100644 --- a/pkg/clusterversion/key_string.go +++ b/pkg/clusterversion/key_string.go @@ -45,11 +45,13 @@ func _() { _ = x[SeparatedIntentsMigration-34] _ = x[PostSeparatedIntentsMigration-35] _ = x[RetryJobsWithExponentialBackoff-36] + _ = x[AutoSpanConfigReconciliationJob-37] + _ = x[SpanConfigurationsTable-38] } -const _Key_name = "Start20_2NodeMembershipStatusMinPasswordLengthAbortSpanBytesCreateLoginPrivilegeHBAForNonTLSV20_2Start21_1CPutInlineReplicaVersionsreplacedTruncatedAndRangeAppliedStateMigrationreplacedPostTruncatedAndRangeAppliedStateMigrationTruncatedAndRangeAppliedStateMigrationPostTruncatedAndRangeAppliedStateMigrationSeparatedIntentsTracingVerbosityIndependentSemanticsClosedTimestampsRaftTransportPriorReadSummariesNonVotingReplicasV21_1Start21_1PLUSStart21_2JoinTokensTableAcquisitionTypeInLeaseHistorySerializeViewUDTsExpressionIndexesDeleteDeprecatedNamespaceTableDescriptorMigrationFixDescriptorsSQLStatsTableDatabaseRoleSettingsTenantUsageTableSQLInstancesTableNewRetryableRangefeedErrorsAlterSystemWebSessionsCreateIndexesSeparatedIntentsMigrationPostSeparatedIntentsMigrationRetryJobsWithExponentialBackoff" +const _Key_name = "Start20_2NodeMembershipStatusMinPasswordLengthAbortSpanBytesCreateLoginPrivilegeHBAForNonTLSV20_2Start21_1CPutInlineReplicaVersionsreplacedTruncatedAndRangeAppliedStateMigrationreplacedPostTruncatedAndRangeAppliedStateMigrationTruncatedAndRangeAppliedStateMigrationPostTruncatedAndRangeAppliedStateMigrationSeparatedIntentsTracingVerbosityIndependentSemanticsClosedTimestampsRaftTransportPriorReadSummariesNonVotingReplicasV21_1Start21_1PLUSStart21_2JoinTokensTableAcquisitionTypeInLeaseHistorySerializeViewUDTsExpressionIndexesDeleteDeprecatedNamespaceTableDescriptorMigrationFixDescriptorsSQLStatsTableDatabaseRoleSettingsTenantUsageTableSQLInstancesTableNewRetryableRangefeedErrorsAlterSystemWebSessionsCreateIndexesSeparatedIntentsMigrationPostSeparatedIntentsMigrationRetryJobsWithExponentialBackoffAutoSpanConfigReconciliationJobSpanConfigurationsTable" -var _Key_index = [...]uint16{0, 9, 29, 46, 60, 80, 92, 97, 106, 116, 131, 177, 227, 265, 307, 323, 359, 388, 406, 423, 428, 441, 450, 465, 494, 511, 528, 577, 591, 604, 624, 640, 657, 684, 719, 744, 773, 804} +var _Key_index = [...]uint16{0, 9, 29, 46, 60, 80, 92, 97, 106, 116, 131, 177, 227, 265, 307, 323, 359, 388, 406, 423, 428, 441, 450, 465, 494, 511, 528, 577, 591, 604, 624, 640, 657, 684, 719, 744, 773, 804, 835, 858} func (i Key) String() string { if i < 0 || i >= Key(len(_Key_index)-1) { diff --git a/pkg/keys/constants.go b/pkg/keys/constants.go index 2c4ce11a0006..2611686b4441 100644 --- a/pkg/keys/constants.go +++ b/pkg/keys/constants.go @@ -410,6 +410,7 @@ const ( DatabaseRoleSettingsTableID = 44 TenantUsageTableID = 45 SQLInstancesTableID = 46 + SpanConfigurationsTableID = 47 // CommentType is type for system.comments DatabaseCommentType = 0 diff --git a/pkg/migration/migrations/BUILD.bazel b/pkg/migration/migrations/BUILD.bazel index 65c82d44e539..bd2336327e87 100644 --- a/pkg/migration/migrations/BUILD.bazel +++ b/pkg/migration/migrations/BUILD.bazel @@ -10,6 +10,7 @@ go_library( "migrations.go", "retry_jobs_with_exponential_backoff.go", "separated_intents.go", + "span_configurations.go", "sql_instances.go", "sql_stats.go", "tenant_usage.go", diff --git a/pkg/migration/migrations/migrations.go b/pkg/migration/migrations/migrations.go index dcf014e3ab1c..09ccef7ae860 100644 --- a/pkg/migration/migrations/migrations.go +++ b/pkg/migration/migrations/migrations.go @@ -110,6 +110,12 @@ var migrations = []migration.Migration{ toCV(clusterversion.RetryJobsWithExponentialBackoff), NoPrecondition, retryJobsWithExponentialBackoff), + migration.NewTenantMigration( + "add the system.span_configurations table", + toCV(clusterversion.SpanConfigurationsTable), + NoPrecondition, + spanConfigurationsTableMigration, + ), } func init() { diff --git a/pkg/migration/migrations/span_configurations.go b/pkg/migration/migrations/span_configurations.go new file mode 100644 index 000000000000..5b4c3a3c075f --- /dev/null +++ b/pkg/migration/migrations/span_configurations.go @@ -0,0 +1,32 @@ +// Copyright 2021 The Cockroach Authors. +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package migrations + +import ( + "context" + + "github.com/cockroachdb/cockroach/pkg/clusterversion" + "github.com/cockroachdb/cockroach/pkg/migration" + "github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema" + "github.com/cockroachdb/cockroach/pkg/startupmigrations" +) + +func spanConfigurationsTableMigration( + ctx context.Context, _ clusterversion.ClusterVersion, d migration.TenantDeps, +) error { + if !d.Codec.ForSystemTenant() { + return nil + } + + return startupmigrations.CreateSystemTable( + ctx, d.DB, d.Codec, d.Settings, systemschema.SpanConfigurationsTable, + ) +} diff --git a/pkg/spanconfig/spanconfigmanager/BUILD.bazel b/pkg/spanconfig/spanconfigmanager/BUILD.bazel index ded7e63ca4db..7759e7a0ab5f 100644 --- a/pkg/spanconfig/spanconfigmanager/BUILD.bazel +++ b/pkg/spanconfig/spanconfigmanager/BUILD.bazel @@ -15,7 +15,6 @@ go_library( "//pkg/sql/sessiondata", "//pkg/sql/sqlutil", "//pkg/util/log", - "//pkg/util/stop", ], ) diff --git a/pkg/sql/catalog/bootstrap/metadata.go b/pkg/sql/catalog/bootstrap/metadata.go index f13679d96492..677aa069d2c4 100644 --- a/pkg/sql/catalog/bootstrap/metadata.go +++ b/pkg/sql/catalog/bootstrap/metadata.go @@ -328,9 +328,9 @@ func addSystemDescriptorsToSchema(target *MetadataSchema) { target.AddDescriptor(keys.SystemDatabaseID, systemschema.StatementStatisticsTable) target.AddDescriptor(keys.SystemDatabaseID, systemschema.TransactionStatisticsTable) target.AddDescriptor(keys.SystemDatabaseID, systemschema.DatabaseRoleSettingsTable) - if target.codec.ForSystemTenant() { target.AddDescriptor(keys.SystemDatabaseID, systemschema.TenantUsageTable) + target.AddDescriptor(keys.SystemDatabaseID, systemschema.SpanConfigurationsTable) } target.AddDescriptor(keys.SystemDatabaseID, systemschema.SQLInstancesTable) } diff --git a/pkg/sql/catalog/descpb/privilege.go b/pkg/sql/catalog/descpb/privilege.go index 8f634dff79df..c02ab6bf85b2 100644 --- a/pkg/sql/catalog/descpb/privilege.go +++ b/pkg/sql/catalog/descpb/privilege.go @@ -562,6 +562,7 @@ var SystemAllowedPrivileges = map[ID]privilege.List{ keys.DatabaseRoleSettingsTableID: privilege.ReadWriteData, keys.TenantUsageTableID: privilege.ReadWriteData, keys.SQLInstancesTableID: privilege.ReadWriteData, + keys.SpanConfigurationsTableID: privilege.ReadWriteData, } // SetOwner sets the owner of the privilege descriptor to the provided string. diff --git a/pkg/sql/catalog/systemschema/system.go b/pkg/sql/catalog/systemschema/system.go index 8e10365412ac..ad2d02a3f0f9 100644 --- a/pkg/sql/catalog/systemschema/system.go +++ b/pkg/sql/catalog/systemschema/system.go @@ -531,6 +531,14 @@ CREATE TABLE system.sql_instances ( session_id BYTES, FAMILY "primary" (id, addr, session_id) )` + + SpanConfigurationsTableSchema = ` +CREATE TABLE system.span_configurations ( + start_key BYTES NOT NULL PRIMARY KEY, + end_key BYTES NOT NULL, + config BYTES NOT NULL, + FAMILY "primary" (start_key, end_key, config) +)` ) func pk(name string) descpb.IndexDescriptor { @@ -2325,6 +2333,37 @@ var ( FormatVersion: descpb.InterleavedFormatVersion, NextMutationID: 1, }) + + // SpanConfigurationsTable is the descriptor for the system tenant's span + // configurations table. + SpanConfigurationsTable = makeTable(descpb.TableDescriptor{ + Name: "span_configurations", + ID: keys.SpanConfigurationsTableID, + ParentID: keys.SystemDatabaseID, + UnexposedParentSchemaID: keys.PublicSchemaID, + Version: 1, + Columns: []descpb.ColumnDescriptor{ + {Name: "start_key", ID: 1, Type: types.Bytes}, + {Name: "end_key", ID: 2, Type: types.Bytes}, + {Name: "config", ID: 3, Type: types.Bytes}, + }, + NextColumnID: 4, + Families: []descpb.ColumnFamilyDescriptor{ + { + Name: "primary", + ID: 0, + ColumnNames: []string{"start_key", "end_key", "config"}, + ColumnIDs: []descpb.ColumnID{1, 2, 3}, + }, + }, + NextFamilyID: 1, + PrimaryIndex: pk("start_key"), + NextIndexID: 2, + Privileges: descpb.NewCustomSuperuserPrivilegeDescriptor( + descpb.SystemAllowedPrivileges[keys.SpanConfigurationsTableID], security.NodeUserName()), + FormatVersion: descpb.InterleavedFormatVersion, + NextMutationID: 1, + }) ) // newCommentPrivilegeDescriptor returns a privilege descriptor for comment table diff --git a/pkg/sql/logictest/testdata/logic_test/grant_table b/pkg/sql/logictest/testdata/logic_test/grant_table index 2b5abd361bad..525513e05d42 100644 --- a/pkg/sql/logictest/testdata/logic_test/grant_table +++ b/pkg/sql/logictest/testdata/logic_test/grant_table @@ -914,16 +914,6 @@ system public join_tokens root GRANT system public join_tokens root INSERT system public join_tokens root SELECT system public join_tokens root UPDATE -system public tenant_usage admin DELETE -system public tenant_usage admin GRANT -system public tenant_usage admin INSERT -system public tenant_usage admin SELECT -system public tenant_usage admin UPDATE -system public tenant_usage root DELETE -system public tenant_usage root GRANT -system public tenant_usage root INSERT -system public tenant_usage root SELECT -system public tenant_usage root UPDATE system public statement_statistics admin GRANT system public statement_statistics admin SELECT system public statement_statistics root GRANT @@ -942,6 +932,16 @@ system public database_role_settings root GRANT system public database_role_settings root INSERT system public database_role_settings root SELECT system public database_role_settings root UPDATE +system public tenant_usage admin DELETE +system public tenant_usage admin GRANT +system public tenant_usage admin INSERT +system public tenant_usage admin SELECT +system public tenant_usage admin UPDATE +system public tenant_usage root DELETE +system public tenant_usage root GRANT +system public tenant_usage root INSERT +system public tenant_usage root SELECT +system public tenant_usage root UPDATE system public sql_instances admin DELETE system public sql_instances admin GRANT system public sql_instances admin INSERT @@ -952,6 +952,16 @@ system public sql_instances root GRANT system public sql_instances root INSERT system public sql_instances root SELECT system public sql_instances root UPDATE +system public span_configurations admin DELETE +system public span_configurations admin GRANT +system public span_configurations admin INSERT +system public span_configurations admin SELECT +system public span_configurations admin UPDATE +system public span_configurations root DELETE +system public span_configurations root GRANT +system public span_configurations root INSERT +system public span_configurations root SELECT +system public span_configurations root UPDATE a pg_extension NULL admin ALL a pg_extension NULL readwrite ALL a pg_extension NULL root ALL @@ -1406,6 +1416,11 @@ system public settings root GRA system public settings root INSERT system public settings root SELECT system public settings root UPDATE +system public span_configurations root DELETE +system public span_configurations root GRANT +system public span_configurations root INSERT +system public span_configurations root SELECT +system public span_configurations root UPDATE system public sql_instances root DELETE system public sql_instances root GRANT system public sql_instances root INSERT diff --git a/pkg/sql/logictest/testdata/logic_test/information_schema b/pkg/sql/logictest/testdata/logic_test/information_schema index fbe8eab51cc3..b89e492befb9 100644 --- a/pkg/sql/logictest/testdata/logic_test/information_schema +++ b/pkg/sql/logictest/testdata/logic_test/information_schema @@ -1355,6 +1355,7 @@ system public transaction_statistics BASE T system public database_role_settings BASE TABLE YES 1 system public tenant_usage BASE TABLE YES 1 system public sql_instances BASE TABLE YES 1 +system public span_configurations BASE TABLE YES 1 statement ok ALTER TABLE other_db.xyz ADD COLUMN j INT @@ -1520,6 +1521,9 @@ system public 630200280_6_1_not_null system public 630200280_6_2_not_null system public settings CHECK NO NO system public 630200280_6_3_not_null system public settings CHECK NO NO system public primary system public settings PRIMARY KEY NO NO +system public 630200280_47_1_not_null system public span_configurations CHECK NO NO +system public 630200280_47_2_not_null system public span_configurations CHECK NO NO +system public primary system public span_configurations PRIMARY KEY NO NO system public 630200280_46_1_not_null system public sql_instances CHECK NO NO system public primary system public sql_instances PRIMARY KEY NO NO system public 630200280_39_1_not_null system public sqlliveness CHECK NO NO @@ -1738,6 +1742,8 @@ system public 630200280_45_1_not_null system public 630200280_45_2_not_null instance_id IS NOT NULL system public 630200280_45_3_not_null next_instance_id IS NOT NULL system public 630200280_46_1_not_null id IS NOT NULL +system public 630200280_47_1_not_null start_key IS NOT NULL +system public 630200280_47_2_not_null end_key IS NOT NULL system public 630200280_4_1_not_null username IS NOT NULL system public 630200280_4_3_not_null isRole IS NOT NULL system public 630200280_5_1_not_null id IS NOT NULL @@ -1800,6 +1806,7 @@ system public role_options option system public role_options username system public primary system public scheduled_jobs schedule_id system public primary system public settings name system public primary +system public span_configurations start_key system public primary system public sql_instances id system public primary system public sqlliveness session_id system public primary system public statement_bundle_chunks id system public primary @@ -2031,12 +2038,15 @@ system public settings lastUpdated system public settings name 1 system public settings value 2 system public settings valueType 4 +system public span_configurations config 3 +system public span_configurations end_key 2 +system public span_configurations start_key 1 system pg_extension spatial_ref_sys auth_name 2 system pg_extension spatial_ref_sys auth_srid 3 system pg_extension spatial_ref_sys proj4text 5 system pg_extension spatial_ref_sys srid 1 system pg_extension spatial_ref_sys srtext 4 -system public sql_instances addr 2 +system public sql_instances addr 2 system public sql_instances id 1 system public sql_instances session_id 3 system public sqlliveness expiration 2 @@ -3040,6 +3050,16 @@ NULL root system public settings NULL root system public settings INSERT NULL NO NULL root system public settings SELECT NULL YES NULL root system public settings UPDATE NULL NO +NULL admin system public span_configurations DELETE NULL NO +NULL admin system public span_configurations GRANT NULL NO +NULL admin system public span_configurations INSERT NULL NO +NULL admin system public span_configurations SELECT NULL YES +NULL admin system public span_configurations UPDATE NULL NO +NULL root system public span_configurations DELETE NULL NO +NULL root system public span_configurations GRANT NULL NO +NULL root system public span_configurations INSERT NULL NO +NULL root system public span_configurations SELECT NULL YES +NULL root system public span_configurations UPDATE NULL NO NULL admin system public sql_instances DELETE NULL NO NULL admin system public sql_instances GRANT NULL NO NULL admin system public sql_instances INSERT NULL NO @@ -3749,6 +3769,16 @@ NULL root system public sql_instances NULL root system public sql_instances INSERT NULL NO NULL root system public sql_instances SELECT NULL YES NULL root system public sql_instances UPDATE NULL NO +NULL admin system public span_configurations DELETE NULL NO +NULL admin system public span_configurations GRANT NULL NO +NULL admin system public span_configurations INSERT NULL NO +NULL admin system public span_configurations SELECT NULL YES +NULL admin system public span_configurations UPDATE NULL NO +NULL root system public span_configurations DELETE NULL NO +NULL root system public span_configurations GRANT NULL NO +NULL root system public span_configurations INSERT NULL NO +NULL root system public span_configurations SELECT NULL YES +NULL root system public span_configurations UPDATE NULL NO statement ok CREATE TABLE other_db.xyz (i INT) diff --git a/pkg/sql/logictest/testdata/logic_test/pg_catalog b/pkg/sql/logictest/testdata/logic_test/pg_catalog index 4f106f71ac0c..4510238f1d4e 100644 --- a/pkg/sql/logictest/testdata/logic_test/pg_catalog +++ b/pkg/sql/logictest/testdata/logic_test/pg_catalog @@ -1037,6 +1037,7 @@ indexrelid indrelid indnatts indisunique indisprimary indisexclusion indim 2268653844 40 4 true true false true false true false false true false 1 2 3 4 0 0 0 0 0 0 0 0 2 2 2 2 NULL NULL 4 2361445172 8 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 2407840836 24 3 true true false true false true false false true false 1 2 3 0 0 0 0 0 0 2 2 2 NULL NULL 3 +2528390115 47 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 2621181440 15 2 false false false false false true false false true false 2 3 3403232968 0 0 0 2 2 NULL NULL 2 2621181441 15 3 false false false false false true false false true false 6 7 2 3403232968 0 0 0 2 2 NULL NULL 2 2621181443 15 1 true true false true false true false false true false 1 0 0 2 NULL NULL 1 @@ -1118,6 +1119,7 @@ indexrelid operator_argument_type_oid operator_argument_position 2407840836 0 1 2407840836 0 2 2407840836 0 3 +2528390115 0 1 2621181440 0 1 2621181440 0 2 2621181441 0 1 diff --git a/pkg/sql/logictest/testdata/logic_test/ranges b/pkg/sql/logictest/testdata/logic_test/ranges index faf395430c01..20e1a89a36a0 100644 --- a/pkg/sql/logictest/testdata/logic_test/ranges +++ b/pkg/sql/logictest/testdata/logic_test/ranges @@ -316,7 +316,8 @@ start_key start_pretty end_key [179] /Table/43 [180] /Table/44 system transaction_statistics · {1} 1 [180] /Table/44 [181] /Table/45 system database_role_settings · {1} 1 [181] /Table/45 [182] /Table/46 system tenant_usage · {1} 1 -[182] /Table/46 [189 137] /Table/53/1 system sql_instances · {1} 1 +[182] /Table/46 [183] /Table/47 system sql_instances · {1} 1 +[183] /Table/47 [189 137] /Table/53/1 system span_configurations · {1} 1 [189 137] /Table/53/1 [189 137 137] /Table/53/1/1 test t · {1} 1 [189 137 137] /Table/53/1/1 [189 137 141 137] /Table/53/1/5/1 test t · {3,4} 3 [189 137 141 137] /Table/53/1/5/1 [189 137 141 138] /Table/53/1/5/2 test t · {1,2,3} 1 @@ -381,7 +382,8 @@ start_key start_pretty end_key [179] /Table/43 [180] /Table/44 system transaction_statistics · {1} 1 [180] /Table/44 [181] /Table/45 system database_role_settings · {1} 1 [181] /Table/45 [182] /Table/46 system tenant_usage · {1} 1 -[182] /Table/46 [189 137] /Table/53/1 system sql_instances · {1} 1 +[182] /Table/46 [183] /Table/47 system sql_instances · {1} 1 +[183] /Table/47 [189 137] /Table/53/1 system span_configurations · {1} 1 [189 137] /Table/53/1 [189 137 137] /Table/53/1/1 test t · {1} 1 [189 137 137] /Table/53/1/1 [189 137 141 137] /Table/53/1/5/1 test t · {3,4} 3 [189 137 141 137] /Table/53/1/5/1 [189 137 141 138] /Table/53/1/5/2 test t · {1,2,3} 1 diff --git a/pkg/sql/logictest/testdata/logic_test/show_source b/pkg/sql/logictest/testdata/logic_test/show_source index 39d719c99540..11b89abab886 100644 --- a/pkg/sql/logictest/testdata/logic_test/show_source +++ b/pkg/sql/logictest/testdata/logic_test/show_source @@ -207,11 +207,12 @@ SELECT * FROM [SHOW TABLES FROM system] ---- schema_name table_name type owner estimated_row_count locality public descriptor table NULL 0 NULL +public span_configurations table NULL 0 NULL +public sql_instances table NULL 0 NULL public tenant_usage table NULL 0 NULL public database_role_settings table NULL 0 NULL public transaction_statistics table NULL 0 NULL public statement_statistics table NULL 0 NULL -public sql_instances table NULL 0 NULL public join_tokens table NULL 0 NULL public migrations table NULL 0 NULL public sqlliveness table NULL 0 NULL @@ -247,9 +248,10 @@ SELECT * FROM [SHOW TABLES FROM system WITH COMMENT] ---- schema_name table_name type owner estimated_row_count locality comment public descriptor table NULL 0 NULL · +public span_configurations table NULL 0 NULL · +public sql_instances table NULL 0 NULL · public tenant_usage table NULL 0 NULL · public database_role_settings table NULL 0 NULL · -public sql_instances table NULL 0 NULL · public transaction_statistics table NULL 0 NULL · public statement_statistics table NULL 0 NULL · public join_tokens table NULL 0 NULL · diff --git a/pkg/sql/logictest/testdata/logic_test/system b/pkg/sql/logictest/testdata/logic_test/system index 27a300066560..0b0972973480 100644 --- a/pkg/sql/logictest/testdata/logic_test/system +++ b/pkg/sql/logictest/testdata/logic_test/system @@ -31,6 +31,7 @@ public role_members table NULL 0 NULL public role_options table NULL 0 NULL public scheduled_jobs table NULL 0 NULL public settings table NULL 0 NULL +public span_configurations table NULL 0 NULL public sql_instances table NULL 0 NULL public sqlliveness table NULL 0 NULL public statement_bundle_chunks table NULL 0 NULL @@ -85,6 +86,7 @@ SELECT id FROM system.descriptor 44 45 46 +47 50 51 52 @@ -392,6 +394,16 @@ system public settings root GRANT system public settings root INSERT system public settings root SELECT system public settings root UPDATE +system public span_configurations admin DELETE +system public span_configurations admin GRANT +system public span_configurations admin INSERT +system public span_configurations admin SELECT +system public span_configurations admin UPDATE +system public span_configurations root DELETE +system public span_configurations root GRANT +system public span_configurations root INSERT +system public span_configurations root SELECT +system public span_configurations root UPDATE system public sql_instances admin DELETE system public sql_instances admin GRANT system public sql_instances admin INSERT diff --git a/pkg/sql/logictest/testdata/logic_test/system_namespace b/pkg/sql/logictest/testdata/logic_test/system_namespace index 5af46dc6eee7..e28219456509 100644 --- a/pkg/sql/logictest/testdata/logic_test/system_namespace +++ b/pkg/sql/logictest/testdata/logic_test/system_namespace @@ -33,6 +33,7 @@ SELECT * FROM system.namespace 1 29 role_options 33 1 29 scheduled_jobs 37 1 29 settings 6 +1 29 span_configurations 47 1 29 sql_instances 46 1 29 sqlliveness 39 1 29 statement_bundle_chunks 34 diff --git a/pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic b/pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic index 94c5ac3bb07c..88bd629d7221 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic +++ b/pkg/sql/opt/exec/execbuilder/testdata/autocommit_nonmetamorphic @@ -41,7 +41,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 # Multi-row insert should auto-commit. query B @@ -62,7 +62,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -86,7 +86,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 2 CPut to (n1,s1):1 +dist sender send r43: sending batch 2 CPut to (n1,s1):1 statement ok ROLLBACK @@ -110,7 +110,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -132,8 +132,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 2 CPut to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 CPut to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 # Insert with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -156,8 +156,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 2 CPut to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 CPut to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 # Another way to test the scenario above: generate an error and ensure that the # mutation was not committed. @@ -192,7 +192,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 1 Put, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Put, 1 EndTxn to (n1,s1):1 # Multi-row upsert should auto-commit. query B @@ -213,7 +213,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -237,7 +237,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 2 Put to (n1,s1):1 +dist sender send r43: sending batch 2 Put to (n1,s1):1 statement ok ROLLBACK @@ -261,7 +261,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -283,8 +283,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 2 Put to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 Put to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 # Upsert with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -307,8 +307,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 2 Put to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 Put to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 # Another way to test the scenario above: generate an error and ensure that the # mutation was not committed. @@ -343,8 +343,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -368,8 +368,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 2 Put to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 2 Put to (n1,s1):1 statement ok ROLLBACK @@ -393,8 +393,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 2 Put, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 2 Put, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -416,9 +416,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 2 Put to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 2 Put to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 # Update with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -441,9 +441,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 2 Put to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 2 Put to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 # Another way to test the scenario above: generate an error and ensure that the # mutation was not committed. @@ -478,7 +478,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 # Multi-row delete should auto-commit. query B @@ -499,7 +499,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 # No auto-commit inside a transaction. statement ok @@ -523,7 +523,7 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 1 DelRng to (n1,s1):1 +dist sender send r43: sending batch 1 DelRng to (n1,s1):1 statement ok ROLLBACK @@ -547,8 +547,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 2 Del, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 2 Del, 1 EndTxn to (n1,s1):1 # TODO(radu): allow non-side-effecting projections. query B @@ -570,9 +570,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 2 Del to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 2 Del to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 # Insert with RETURNING statement with side-effects should not auto-commit. # In this case division can (in principle) error out. @@ -595,9 +595,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 2 Del to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 2 Del to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 statement ok INSERT INTO ab VALUES (12, 0); @@ -644,9 +644,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 2 CPut to (n1,s1):1 -dist sender send r42: sending batch 2 Get to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 CPut to (n1,s1):1 +dist sender send r43: sending batch 2 Get to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 query B SELECT count(*) > 0 FROM [ @@ -667,10 +667,10 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 1 Put to (n1,s1):1 -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 1 Put to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 query B SELECT count(*) > 0 FROM [ @@ -692,10 +692,10 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 1 Get to (n1,s1):1 -dist sender send r42: sending batch 1 Del to (n1,s1):1 -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 Get to (n1,s1):1 +dist sender send r43: sending batch 1 Del to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 # Test with a single cascade, which should use autocommit. statement ok @@ -719,9 +719,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 1 DelRng to (n1,s1):1 -dist sender send r42: sending batch 1 Scan to (n1,s1):1 -dist sender send r42: sending batch 1 Del, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 DelRng to (n1,s1):1 +dist sender send r43: sending batch 1 Scan to (n1,s1):1 +dist sender send r43: sending batch 1 Del, 1 EndTxn to (n1,s1):1 # ----------------------- # Multiple mutation tests @@ -749,9 +749,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 2 CPut to (n1,s1):1 -dist sender send r42: sending batch 2 CPut to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 CPut to (n1,s1):1 +dist sender send r43: sending batch 2 CPut to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 query B SELECT count(*) > 0 FROM [ @@ -774,6 +774,6 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%QueryTxn%' AND operation NOT LIKE '%async%' ---- -dist sender send r42: sending batch 2 CPut to (n1,s1):1 -dist sender send r42: sending batch 2 CPut to (n1,s1):1 -dist sender send r42: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 2 CPut to (n1,s1):1 +dist sender send r43: sending batch 2 CPut to (n1,s1):1 +dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 diff --git a/pkg/sql/opt/exec/execbuilder/testdata/delete b/pkg/sql/opt/exec/execbuilder/testdata/delete index c6ac66c3f129..1a8f50c1464d 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/delete +++ b/pkg/sql/opt/exec/execbuilder/testdata/delete @@ -231,9 +231,9 @@ SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] WHERE message LIKE '%DelRange%' OR message LIKE '%DelRng%' ---- batch flow coordinator DelRange /Table/57/1 - /Table/57/2 -dist sender send r42: sending batch 1 DelRng to (n1,s1):1 +dist sender send r43: sending batch 1 DelRng to (n1,s1):1 batch flow coordinator DelRange /Table/57/1/601/0 - /Table/57/2 -dist sender send r42: sending batch 1 DelRng to (n1,s1):1 +dist sender send r43: sending batch 1 DelRng to (n1,s1):1 # Ensure that DelRange requests are autocommitted when DELETE FROM happens on a # chunk of fewer than 600 keys. @@ -249,7 +249,7 @@ SELECT operation, message FROM [SHOW KV TRACE FOR SESSION] WHERE message LIKE '%DelRange%' OR message LIKE '%sending batch%' ---- batch flow coordinator DelRange /Table/57/1/5 - /Table/57/1/5/# -dist sender send r42: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 +dist sender send r43: sending batch 1 DelRng, 1 EndTxn to (n1,s1):1 # Test use of fast path when there are interleaved tables. diff --git a/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic b/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic index d932e476de46..a6dd1434fb55 100644 --- a/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic +++ b/pkg/sql/opt/exec/execbuilder/testdata/show_trace_nonmetamorphic @@ -238,7 +238,7 @@ SET tracing = on; INSERT INTO t.kv3 (k, v) VALUES (1,1); SET tracing = off query T SELECT message FROM [SHOW TRACE FOR SESSION] WHERE message LIKE e'%1 CPut, 1 EndTxn%' AND message NOT LIKE e'%proposing command%' ---- -r43: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 +r44: sending batch 1 CPut, 1 EndTxn to (n1,s1):1 node received request: 1 CPut, 1 EndTxn # Check that we can run set tracing regardless of the current tracing state. @@ -314,9 +314,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r43: sending batch 1 CPut to (n1,s1):1 -dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 -dist sender send r43: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r44: sending batch 1 CPut to (n1,s1):1 +dist sender send r44: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r44: sending batch 2 CPut, 1 EndTxn to (n1,s1):1 # Make another session trace. statement ok @@ -345,9 +345,9 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r43: sending batch 4 CPut, 1 EndTxn to (n1,s1):1 -dist sender send r43: sending batch 5 CPut to (n1,s1):1 -dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r44: sending batch 4 CPut, 1 EndTxn to (n1,s1):1 +dist sender send r44: sending batch 5 CPut to (n1,s1):1 +dist sender send r44: sending batch 1 EndTxn to (n1,s1):1 # make a table with some big strings in it. statement ok @@ -366,8 +366,8 @@ WHERE message LIKE '%r$rangeid: sending batch%' AND message NOT LIKE '%PushTxn%' AND message NOT LIKE '%QueryTxn%' ---- -dist sender send r43: sending batch 6 CPut to (n1,s1):1 -dist sender send r43: sending batch 6 CPut to (n1,s1):1 -dist sender send r43: sending batch 6 CPut to (n1,s1):1 -dist sender send r43: sending batch 6 CPut to (n1,s1):1 -dist sender send r43: sending batch 1 EndTxn to (n1,s1):1 +dist sender send r44: sending batch 6 CPut to (n1,s1):1 +dist sender send r44: sending batch 6 CPut to (n1,s1):1 +dist sender send r44: sending batch 6 CPut to (n1,s1):1 +dist sender send r44: sending batch 6 CPut to (n1,s1):1 +dist sender send r44: sending batch 1 EndTxn to (n1,s1):1 diff --git a/pkg/sql/pgwire/pgwire_test.go b/pkg/sql/pgwire/pgwire_test.go index b7c725f721bb..e5dc76e582d3 100644 --- a/pkg/sql/pgwire/pgwire_test.go +++ b/pkg/sql/pgwire/pgwire_test.go @@ -561,7 +561,7 @@ func TestPGPreparedQuery(t *testing.T) { Results("users", "primary", false, 3, "isRole", "N/A", true, false), }}, {"SHOW TABLES FROM system", []preparedQueryTest{ - baseTest.Results("public", "comments", "table", gosql.NullString{}, 0, gosql.NullString{}).Others(34), + baseTest.Results("public", "comments", "table", gosql.NullString{}, 0, gosql.NullString{}).Others(35), }}, {"SHOW SCHEMAS FROM system", []preparedQueryTest{ baseTest.Results("crdb_internal", gosql.NullString{}).Others(4), diff --git a/pkg/sql/tests/system_table_test.go b/pkg/sql/tests/system_table_test.go index 5a9b2fbe371d..61b304346bbe 100644 --- a/pkg/sql/tests/system_table_test.go +++ b/pkg/sql/tests/system_table_test.go @@ -197,6 +197,7 @@ func TestSystemTableLiterals(t *testing.T) { {keys.DatabaseRoleSettingsTableID, systemschema.DatabaseRoleSettingsTableSchema, systemschema.DatabaseRoleSettingsTable}, {keys.TenantUsageTableID, systemschema.TenantUsageTableSchema, systemschema.TenantUsageTable}, {keys.SQLInstancesTableID, systemschema.SQLInstancesTableSchema, systemschema.SQLInstancesTable}, + {keys.SpanConfigurationsTableID, systemschema.SpanConfigurationsTableSchema, systemschema.SpanConfigurationsTable}, } { privs := *test.pkg.GetPrivileges() gen, err := sql.CreateTestTableDescriptor( diff --git a/pkg/sql/tests/testdata/initial_keys b/pkg/sql/tests/testdata/initial_keys index 888d13a6b88d..7e7d146e10bb 100644 --- a/pkg/sql/tests/testdata/initial_keys +++ b/pkg/sql/tests/testdata/initial_keys @@ -1,6 +1,6 @@ initial-keys tenant=system ---- -81 keys: +83 keys: /System/"desc-idgen" /Table/3/1/1/2/1 /Table/3/1/3/2/1 @@ -38,6 +38,7 @@ initial-keys tenant=system /Table/3/1/44/2/1 /Table/3/1/45/2/1 /Table/3/1/46/2/1 + /Table/3/1/47/2/1 /Table/5/1/0/2/1 /Table/5/1/1/2/1 /Table/5/1/16/2/1 @@ -68,6 +69,7 @@ initial-keys tenant=system /NamespaceTable/30/1/1/29/"role_options"/4/1 /NamespaceTable/30/1/1/29/"scheduled_jobs"/4/1 /NamespaceTable/30/1/1/29/"settings"/4/1 + /NamespaceTable/30/1/1/29/"span_configurations"/4/1 /NamespaceTable/30/1/1/29/"sql_instances"/4/1 /NamespaceTable/30/1/1/29/"sqlliveness"/4/1 /NamespaceTable/30/1/1/29/"statement_bundle_chunks"/4/1 @@ -82,7 +84,7 @@ initial-keys tenant=system /NamespaceTable/30/1/1/29/"users"/4/1 /NamespaceTable/30/1/1/29/"web_sessions"/4/1 /NamespaceTable/30/1/1/29/"zones"/4/1 -36 splits: +37 splits: /Table/11 /Table/12 /Table/13 @@ -119,6 +121,7 @@ initial-keys tenant=system /Table/44 /Table/45 /Table/46 + /Table/47 initial-keys tenant=5 ----