Skip to content

Commit

Permalink
sql: add system.span_configurations for kv span configs
Browse files Browse the repository at this point in the history
Part of cockroachdb#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.
  • Loading branch information
irfansharif committed Aug 17, 2021
1 parent f5d1d74 commit 149e19f
Show file tree
Hide file tree
Showing 32 changed files with 287 additions and 109 deletions.
2 changes: 1 addition & 1 deletion docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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://<ui>/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 '<major>.<minor>'
version version 21.1-136 set the active cluster version in the format '<major>.<minor>'
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@
<tr><td><code>trace.debug.enable</code></td><td>boolean</td><td><code>false</code></td><td>if set, traces for recent requests can be seen at https://<ui>/debug/requests</td></tr>
<tr><td><code>trace.lightstep.token</code></td><td>string</td><td><code></code></td><td>if set, traces go to Lightstep using this token</td></tr>
<tr><td><code>trace.zipkin.collector</code></td><td>string</td><td><code></code></td><td>if set, traces go to the given Zipkin instance (example: '127.0.0.1:9411'). Only one tracer can be configured at a time.</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>21.1-134</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>21.1-136</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
</tbody>
</table>
3 changes: 3 additions & 0 deletions pkg/ccl/backupccl/system_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/testdata/doctor/test_examine_cluster
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions pkg/cli/testdata/zip/partial1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 4 additions & 2 deletions pkg/cli/testdata/zip/partial1_excluded
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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://...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 4 additions & 2 deletions pkg/cli/testdata/zip/partial2
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
3 changes: 2 additions & 1 deletion pkg/cli/testdata/zip/testzip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
18 changes: 15 additions & 3 deletions pkg/cli/testdata/zip/testzip_concurrent
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...
Expand Down Expand Up @@ -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...
Expand All @@ -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 ...
Expand Down Expand Up @@ -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...
Expand All @@ -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 ...
Expand Down Expand Up @@ -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...
Expand Down
7 changes: 7 additions & 0 deletions pkg/clusterversion/cockroach_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
)
Expand Down Expand Up @@ -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.
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/clusterversion/key_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/keys/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ const (
DatabaseRoleSettingsTableID = 44
TenantUsageTableID = 45
SQLInstancesTableID = 46
SpanConfigurationsTableID = 47

// CommentType is type for system.comments
DatabaseCommentType = 0
Expand Down
1 change: 1 addition & 0 deletions pkg/migration/migrations/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions pkg/migration/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
32 changes: 32 additions & 0 deletions pkg/migration/migrations/span_configurations.go
Original file line number Diff line number Diff line change
@@ -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,
)
}
1 change: 0 additions & 1 deletion pkg/spanconfig/spanconfigmanager/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ go_library(
"//pkg/sql/sessiondata",
"//pkg/sql/sqlutil",
"//pkg/util/log",
"//pkg/util/stop",
],
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/catalog/bootstrap/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/catalog/descpb/privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 149e19f

Please sign in to comment.