Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
79009: catalog: protobuf and cluster versioning for autostats table settings r=msirek a=msirek

This commit adds protobuf and cluster versioning needed for cockroachdb#78110

Release note: none

Co-authored-by: Mark Sirek <sirek@cockroachlabs.com>
  • Loading branch information
craig[bot] and Mark Sirek committed Mar 30, 2022
2 parents dce0a30 + 2c6fc9c commit bd80d60
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 6 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 @@ -193,4 +193,4 @@ trace.jaeger.agent string the address of a Jaeger agent to receive traces using
trace.opentelemetry.collector string address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.
trace.span_registry.enabled boolean true if set, ongoing traces can be seen at https://<ui>/#/debug/tracez
trace.zipkin.collector string the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.
version version 21.2-98 set the active cluster version in the format '<major>.<minor>'
version version 21.2-100 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 @@ -209,6 +209,6 @@
<tr><td><code>trace.opentelemetry.collector</code></td><td>string</td><td><code></code></td><td>address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.</td></tr>
<tr><td><code>trace.span_registry.enabled</code></td><td>boolean</td><td><code>true</code></td><td>if set, ongoing traces can be seen at https://<ui>/#/debug/tracez</td></tr>
<tr><td><code>trace.zipkin.collector</code></td><td>string</td><td><code></code></td><td>the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>21.2-98</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.2-100</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
</tbody>
</table>
9 changes: 8 additions & 1 deletion pkg/clusterversion/cockroach_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ const (
// virtual table, which sends a QueryLocksRequest RPC to all cluster ranges.
ClusterLocksVirtualTable

// AutoStatsTableSettings is the version where we allow auto stats related
// table settings.
AutoStatsTableSettings

// *************************************************
// Step (1): Add new versions here.
// Do not add new versions to a patch release.
Expand Down Expand Up @@ -550,7 +554,10 @@ var versionsSingleton = keyedVersions{
Key: ClusterLocksVirtualTable,
Version: roachpb.Version{Major: 21, Minor: 2, Internal: 98},
},

{
Key: AutoStatsTableSettings,
Version: roachpb.Version{Major: 21, Minor: 2, Internal: 100},
},
// *************************************************
// Step (2): Add new versions here.
// Do not add new versions to a patch release.
Expand Down
5 changes: 3 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.

15 changes: 15 additions & 0 deletions pkg/sql/catalog/catpb/catalog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,18 @@ message RowLevelTTL {
// the relation name.
optional bool label_metrics = 10 [(gogoproto.nullable) = false];
}

// AutoStatsSettings represents settings related to automatic statistics
// collection specified at the table level, as indicated in the `WITH` clause
// output of `SHOW CREATE TABLE`.
// Each setting is nullable so queries of the descriptor in JSON form
// only list values which have been set. Protobuf type double is float64 in Go.
message AutoStatsSettings {
option (gogoproto.equal) = true;
// sql.stats.automatic_collection.enabled
optional bool enabled = 1;
// sql.stats.automatic_collection.min_stale_rows
optional int64 min_stale_rows = 2;
// sql.stats.automatic_collection.fraction_stale_rows
optional double fraction_stale_rows = 3;
}
5 changes: 4 additions & 1 deletion pkg/sql/catalog/descpb/structured.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,10 @@ message TableDescriptor {
optional uint32 next_constraint_id = 49 [(gogoproto.nullable) = false,
(gogoproto.customname) = "NextConstraintID", (gogoproto.casttype) = "ConstraintID"];

// Next ID: 51
// AutoStatsSettings are table settings related to auto stats collection.
optional cockroach.sql.catalog.catpb.AutoStatsSettings auto_stats_settings = 51 [(gogoproto.customname)="AutoStatsSettings"];

// Next ID: 52
}

// SurvivalGoal is the survival goal for a database.
Expand Down
13 changes: 13 additions & 0 deletions pkg/sql/catalog/tabledesc/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ var validationMap = []struct {
"ExcludeDataFromBackup": {status: thisFieldReferencesNoObjects},
"NextConstraintID": {status: iSolemnlySwearThisFieldIsValidated},
"DeclarativeSchemaChangerState": {status: iSolemnlySwearThisFieldIsValidated},
"AutoStatsSettings": {
status: todoIAmKnowinglyAddingTechDebt,
reason: "initial import: TODO(msirek): add validation"},
},
},
{
Expand Down Expand Up @@ -289,6 +292,16 @@ var validationMap = []struct {
"DeclarativeSchemaChangerState": {status: thisFieldReferencesNoObjects},
},
},
{
// TODO(msirek): These fields can't be set until #78110 merges. That PR
// will add validation.
obj: catpb.AutoStatsSettings{},
fieldMap: map[string]validationStatusInfo{
"Enabled": {status: thisFieldReferencesNoObjects},
"MinStaleRows": {status: thisFieldReferencesNoObjects},
"FractionStaleRows": {status: thisFieldReferencesNoObjects},
},
},
}

type validationStatusInfo struct {
Expand Down

0 comments on commit bd80d60

Please sign in to comment.