Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
128032: Reapply "bootstrap: create an explicit zoneconfig for timeseries data" r=rafiss a=rafiss

This partially reverts commit f9d47ce.

This time, rather than copying over the full zone config for the default range to the timeseries range, we only copy over gc.ttlseconds. This means that other attributes, most notably the replication factor, will be inherited from the default range.

This will make it more clear that the timeseries zone config can be changed independently from all the other zone configs.

fixes #123762

Release note (ops change): New clusters that are initialized for the first time will now have a zone config defined for the `timeseries` range. This zone config only specifies the gc.ttlseconds, so all the other attributes are inherited from the zone config of the `default` range, as they were before.

Clusters that are upgraded to v24.3 from a previous version will also
have this zone configuration applied to the timeseries range, as long as
that range does not already have a zone config.

129053: sql/parser: only retain scanned SQL comments when necessary r=mgartner a=mgartner

In #86968 the scanner gained the ability to retain comments in scanned
SQL strings, and this was an always-on feature. However, the comments
are only used when populating the crdb_internal.cluster_queries table,
see `sql.formatActiveQuery`. Now, comments are only retained when the
parser is used from this function, reducing allocations for all other
cases.

Fixes #127713

Release note: None


Co-authored-by: Rafi Shamim <rafi@cockroachlabs.com>
Co-authored-by: Marcus Gartner <marcus@cockroachlabs.com>
  • Loading branch information
3 people committed Aug 15, 2024
3 parents 7b3e097 + 0ae91a1 + f9e0f16 commit ec66ae7
Show file tree
Hide file tree
Showing 31 changed files with 370 additions and 61 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 @@ -392,4 +392,4 @@ trace.snapshot.rate duration 0s if non-zero, interval at which background trace
trace.span_registry.enabled boolean true if set, ongoing traces can be seen at https://<ui>/#/debug/tracez application
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. application
ui.display_timezone enumeration etc/utc the timezone used to format timestamps in the ui [etc/utc = 0, america/new_york = 1] application
version version 1000024.2-upgrading-to-1000024.3-step-004 set the active cluster version in the format '<major>.<minor>' application
version version 1000024.2-upgrading-to-1000024.3-step-006 set the active cluster version in the format '<major>.<minor>' application
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,6 @@
<tr><td><div id="setting-trace-span-registry-enabled" class="anchored"><code>trace.span_registry.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>if set, ongoing traces can be seen at https://&lt;ui&gt;/#/debug/tracez</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-trace-zipkin-collector" class="anchored"><code>trace.zipkin.collector</code></div></td><td>string</td><td><code></code></td><td>the address of a Zipkin instance to receive traces, as &lt;host&gt;:&lt;port&gt;. If no port is specified, 9411 will be used.</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-ui-display-timezone" class="anchored"><code>ui.display_timezone</code></div></td><td>enumeration</td><td><code>etc/utc</code></td><td>the timezone used to format timestamps in the ui [etc/utc = 0, america/new_york = 1]</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000024.2-upgrading-to-1000024.3-step-004</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000024.2-upgrading-to-1000024.3-step-006</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td><td>Serverless/Dedicated/Self-Hosted</td></tr>
</tbody>
</table>
2 changes: 2 additions & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ ALL_TESTS = [
"//pkg/sql/logictest/tests/5node-disk:5node-disk_test",
"//pkg/sql/logictest/tests/5node:5node_test",
"//pkg/sql/logictest/tests/cockroach-go-testserver-24.1:cockroach-go-testserver-24_1_test",
"//pkg/sql/logictest/tests/cockroach-go-testserver-24.2:cockroach-go-testserver-24_2_test",
"//pkg/sql/logictest/tests/fakedist-disk:fakedist-disk_test",
"//pkg/sql/logictest/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/sql/logictest/tests/fakedist:fakedist_test",
Expand Down Expand Up @@ -1948,6 +1949,7 @@ GO_TARGETS = [
"//pkg/sql/logictest/tests/5node-disk:5node-disk_test",
"//pkg/sql/logictest/tests/5node:5node_test",
"//pkg/sql/logictest/tests/cockroach-go-testserver-24.1:cockroach-go-testserver-24_1_test",
"//pkg/sql/logictest/tests/cockroach-go-testserver-24.2:cockroach-go-testserver-24_2_test",
"//pkg/sql/logictest/tests/fakedist-disk:fakedist-disk_test",
"//pkg/sql/logictest/tests/fakedist-vec-off:fakedist-vec-off_test",
"//pkg/sql/logictest/tests/fakedist:fakedist_test",
Expand Down
3 changes: 3 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/crdb_internal
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ SELECT zone_id, target FROM crdb_internal.zones ORDER BY 1
0 RANGE default
16 RANGE meta
17 RANGE system
18 RANGE timeseries
22 RANGE liveness
111 TABLE test.public.t4
111 INDEX test.public.t4@myt4index
Expand Down Expand Up @@ -109,6 +110,8 @@ RANGE system ALTER RANGE system CONFIGURE ZONE USING
num_replicas = 5,
constraints = '[]',
lease_preferences = '[]'
RANGE timeseries ALTER RANGE timeseries CONFIGURE ZONE USING
gc.ttlseconds = 14400
TABLE test.public.t4 ALTER TABLE test.public.t4 CONFIGURE ZONE USING
num_replicas = 7

Expand Down
55 changes: 28 additions & 27 deletions pkg/ccl/logictestccl/testdata/logic_test/zone
Original file line number Diff line number Diff line change
Expand Up @@ -616,33 +616,34 @@ SELECT target, range_name, database_name, table_name, index_name, partition_name
FROM crdb_internal.zones
ORDER BY target
----
DATABASE "my database" NULL my database NULL NULL NULL
DATABASE system NULL system NULL NULL NULL
INDEX "my database".public."my table"@"my index" NULL my database my table my index NULL
INDEX test.public.t36642@secondary NULL test t36642 secondary NULL
INDEX test.public.t36642@tertiary NULL test t36642 tertiary NULL
INDEX test.public.t36644@secondary NULL test t36644 secondary NULL
INDEX test.public.t36644@tertiary NULL test t36644 tertiary NULL
INDEX test.public.t@secondary NULL test t secondary NULL
INDEX test.public.t@tertiary NULL test t tertiary NULL
PARTITION "my partition" OF INDEX "my database".public."my table"@"my index" NULL my database my table my index my partition
PARTITION "my partition" OF INDEX "my database".public."my table"@"my table_pkey" NULL my database my table my table_pkey my partition
PARTITION x1_idx OF INDEX test.public.t38391@foo NULL test t38391 foo x1_idx
RANGE default default NULL NULL NULL NULL
RANGE liveness liveness NULL NULL NULL NULL
RANGE meta meta NULL NULL NULL NULL
RANGE system system NULL NULL NULL NULL
TABLE "my database".public."my table" NULL my database my table NULL NULL
TABLE system.public.lease NULL system lease NULL NULL
TABLE system.public.replication_constraint_stats NULL system replication_constraint_stats NULL NULL
TABLE system.public.replication_stats NULL system replication_stats NULL NULL
TABLE system.public.span_stats_tenant_boundaries NULL system span_stats_tenant_boundaries NULL NULL
TABLE system.public.statement_activity NULL system statement_activity NULL NULL
TABLE system.public.statement_statistics NULL system statement_statistics NULL NULL
TABLE system.public.tenant_usage NULL system tenant_usage NULL NULL
TABLE system.public.transaction_activity NULL system transaction_activity NULL NULL
TABLE system.public.transaction_statistics NULL system transaction_statistics NULL NULL
TABLE test.public.t NULL test t NULL NULL
DATABASE "my database" NULL my database NULL NULL NULL
DATABASE system NULL system NULL NULL NULL
INDEX "my database".public."my table"@"my index" NULL my database my table my index NULL
INDEX test.public.t36642@secondary NULL test t36642 secondary NULL
INDEX test.public.t36642@tertiary NULL test t36642 tertiary NULL
INDEX test.public.t36644@secondary NULL test t36644 secondary NULL
INDEX test.public.t36644@tertiary NULL test t36644 tertiary NULL
INDEX test.public.t@secondary NULL test t secondary NULL
INDEX test.public.t@tertiary NULL test t tertiary NULL
PARTITION "my partition" OF INDEX "my database".public."my table"@"my index" NULL my database my table my index my partition
PARTITION "my partition" OF INDEX "my database".public."my table"@"my table_pkey" NULL my database my table my table_pkey my partition
PARTITION x1_idx OF INDEX test.public.t38391@foo NULL test t38391 foo x1_idx
RANGE default default NULL NULL NULL NULL
RANGE liveness liveness NULL NULL NULL NULL
RANGE meta meta NULL NULL NULL NULL
RANGE system system NULL NULL NULL NULL
RANGE timeseries timeseries NULL NULL NULL NULL
TABLE "my database".public."my table" NULL my database my table NULL NULL
TABLE system.public.lease NULL system lease NULL NULL
TABLE system.public.replication_constraint_stats NULL system replication_constraint_stats NULL NULL
TABLE system.public.replication_stats NULL system replication_stats NULL NULL
TABLE system.public.span_stats_tenant_boundaries NULL system span_stats_tenant_boundaries NULL NULL
TABLE system.public.statement_activity NULL system statement_activity NULL NULL
TABLE system.public.statement_statistics NULL system statement_statistics NULL NULL
TABLE system.public.tenant_usage NULL system tenant_usage NULL NULL
TABLE system.public.transaction_activity NULL system transaction_activity NULL NULL
TABLE system.public.transaction_statistics NULL system transaction_statistics NULL NULL
TABLE test.public.t NULL test t NULL NULL

# Test the zone information being displayed in SHOW CREATE
statement ok
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ SELECT id FROM system.zones
11
16
17
18
22
25
27
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
# RANGE DEFAULT is akin to a full reconciliation.


# ID 18 is for the time series range which is the only named zone that doesn't
# have an entry in `system.zones` at bootstrap. It should inherit from RANGE
# DEFAULT.
# ID 18 is for the time series range. At bootstrap, it has an explicit zone
# config which should inherit from RANGE DEFAULT.
query-sql
SELECT count(*) FROM system.zones WHERE id=18
----
0
1

translate named-zone=timeseries
----
Expand Down
6 changes: 6 additions & 0 deletions pkg/clusterversion/cockroach_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ const (
// of the StoreLiveness fabric.
V24_3_StoreLivenessEnabled

// V24_3_AddTimeseriesZoneConfig is the version that adds an explicit zone
// config for the timeseries range if one does not exist currently.
V24_3_AddTimeseriesZoneConfig

// *************************************************
// Step (1) Add new versions above this comment.
// Do not add new versions to a patch release.
Expand Down Expand Up @@ -270,6 +274,8 @@ var versionTable = [numKeys]roachpb.Version{

V24_3_StoreLivenessEnabled: {Major: 24, Minor: 2, Internal: 4},

V24_3_AddTimeseriesZoneConfig: {Major: 24, Minor: 2, Internal: 6},

// *************************************************
// Step (2): Add new versions above this comment.
// Do not add new versions to a patch release.
Expand Down
7 changes: 7 additions & 0 deletions pkg/sql/catalog/bootstrap/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,12 @@ func InitialZoneConfigKVs(
metaRangeZoneConf := protoutil.Clone(defaultSystemZoneConfig).(*zonepb.ZoneConfig)
livenessZoneConf := protoutil.Clone(defaultSystemZoneConfig).(*zonepb.ZoneConfig)

// The timeseries zone should inherit everything except for gc.ttlseconds from
// the default zone. We create it explicitly here so it's clearly visible
// when using SHOW ALL ZONE CONFIGURATIONS.
timeseriesZoneConf := zonepb.NewZoneConfig()
timeseriesZoneConf.GC = &zonepb.GCPolicy{TTLSeconds: defaultZoneConfig.GC.TTLSeconds}

// .meta zone config entry with a shorter GC time.
metaRangeZoneConf.GC.TTLSeconds = 60 * 60 // 1h

Expand All @@ -534,6 +540,7 @@ func InitialZoneConfigKVs(
add(keys.MetaRangesID, metaRangeZoneConf)
add(keys.LivenessRangesID, livenessZoneConf)
add(keys.SystemRangesID, systemZoneConf)
add(keys.TimeseriesRangesID, timeseriesZoneConf)
add(keys.SystemDatabaseID, systemZoneConf)
add(keys.ReplicationConstraintStatsTableID, replicationConstraintStatsZoneConf)
add(keys.ReplicationStatsTableID, replicationStatsZoneConf)
Expand Down
Loading

0 comments on commit ec66ae7

Please sign in to comment.