From 103bd54659d0dd57ab26e7a1fd99c1ab7f21da21 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Tue, 30 Jul 2024 12:48:37 -0400 Subject: [PATCH 1/3] Reapply "bootstrap: create an explicit zoneconfig for timeseries data" This partially reverts commit f9d47ce1c0165e9b2696fd65d0bfc9a8db94d340. 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. 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. --- .../testdata/logic_test/crdb_internal | 3 + pkg/ccl/logictestccl/testdata/logic_test/zone | 55 ++++++++++--------- .../full_translate_named_zones_deleted | 1 + .../testdata/named_zones | 7 +-- pkg/sql/catalog/bootstrap/metadata.go | 7 +++ pkg/sql/catalog/bootstrap/testdata/testdata | 3 +- .../internal/catkv/testdata/testdata_system | 2 + .../testdata/logic_test/crdb_internal | 1 - .../logic_test/zone_config_system_tenant | 14 ++++- pkg/sql/tests/system_table_test.go | 2 +- pkg/sql/tests/testdata/initial_keys | 3 +- 11 files changed, 61 insertions(+), 37 deletions(-) diff --git a/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal b/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal index 02074c148e72..280eec80d01b 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal +++ b/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal @@ -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 @@ -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 diff --git a/pkg/ccl/logictestccl/testdata/logic_test/zone b/pkg/ccl/logictestccl/testdata/logic_test/zone index 5ebf9e9520f9..e1ed1bbfa546 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/zone +++ b/pkg/ccl/logictestccl/testdata/logic_test/zone @@ -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 diff --git a/pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/full_translate_named_zones_deleted b/pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/full_translate_named_zones_deleted index f6fccf3b144f..dc1446d9e896 100644 --- a/pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/full_translate_named_zones_deleted +++ b/pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/full_translate_named_zones_deleted @@ -12,6 +12,7 @@ SELECT id FROM system.zones 11 16 17 +18 22 25 27 diff --git a/pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/named_zones b/pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/named_zones index cd3ab2fb49f4..a971d9c64294 100644 --- a/pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/named_zones +++ b/pkg/ccl/spanconfigccl/spanconfigsqltranslatorccl/testdata/named_zones @@ -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 ---- diff --git a/pkg/sql/catalog/bootstrap/metadata.go b/pkg/sql/catalog/bootstrap/metadata.go index 1d461a306985..5dd28f26e40d 100644 --- a/pkg/sql/catalog/bootstrap/metadata.go +++ b/pkg/sql/catalog/bootstrap/metadata.go @@ -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 @@ -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) diff --git a/pkg/sql/catalog/bootstrap/testdata/testdata b/pkg/sql/catalog/bootstrap/testdata/testdata index 061dabce425a..d93450d6fc95 100644 --- a/pkg/sql/catalog/bootstrap/testdata/testdata +++ b/pkg/sql/catalog/bootstrap/testdata/testdata @@ -1,4 +1,4 @@ -system hash=3d3210258c9ec86c5b1aa619be83379f5a23b5da269ec9f90fa68c5c6f87fc4f +system hash=6e9fc47c42475875a43765bbe4cff5d87f646b078e8d6bc69f239a8ae2dbb77b ---- [{"key":"8b"} ,{"key":"8b89898a89","value":"0312450a0673797374656d10011a250a0d0a0561646d696e1080101880100a0c0a04726f6f7410801018801012046e6f646518032200280140004a006a0a08d8843d100218002002"} @@ -65,6 +65,7 @@ system hash=3d3210258c9ec86c5b1aa619be83379f5a23b5da269ec9f90fa68c5c6f87fc4f ,{"key":"8d89938a89","value":"03220308d804500158017800"} ,{"key":"8d89988a89","value":"031080808040188080808002220308901c2805500058007801"} ,{"key":"8d89998a89","value":"031080808040188080808002220308c0702805500058007801"} +,{"key":"8d899a8a89","value":"03220308c070500058007800"} ,{"key":"8d899e8a89","value":"031080808040188080808002220308d8042805500058007801"} ,{"key":"8d89a18a89","value":"03220308d804500158017800"} ,{"key":"8d89a38a89","value":"03220308d804500158017800"} diff --git a/pkg/sql/catalog/internal/catkv/testdata/testdata_system b/pkg/sql/catalog/internal/catkv/testdata/testdata_system index 2dd11cd354bb..1ee37bf844bc 100644 --- a/pkg/sql/catalog/internal/catkv/testdata/testdata_system +++ b/pkg/sql/catalog/internal/catkv/testdata/testdata_system @@ -247,6 +247,8 @@ catalog: zone: gc.ttlseconds=3600 "017": zone: gc.ttlseconds=14400 + "018": + zone: gc.ttlseconds=14400 "019": descriptor: relation namespace: (1, 29, "web_sessions") diff --git a/pkg/sql/logictest/testdata/logic_test/crdb_internal b/pkg/sql/logictest/testdata/logic_test/crdb_internal index d03ac85717ea..e783e5847265 100644 --- a/pkg/sql/logictest/testdata/logic_test/crdb_internal +++ b/pkg/sql/logictest/testdata/logic_test/crdb_internal @@ -567,7 +567,6 @@ SELECT 'schema.bar'::regclass::int statement ok INSERT INTO system.zones (id, config) VALUES - (18, (SELECT raw_config_protobuf FROM crdb_internal.zones WHERE zone_id = 0)), ($testdb_id, (SELECT raw_config_protobuf FROM crdb_internal.zones WHERE zone_id = 0)), ($testdb_foo_id, (SELECT raw_config_protobuf FROM crdb_internal.zones WHERE zone_id = 0)), ($schema_bar_id, (SELECT raw_config_protobuf FROM crdb_internal.zones WHERE zone_id = 0)) diff --git a/pkg/sql/logictest/testdata/logic_test/zone_config_system_tenant b/pkg/sql/logictest/testdata/logic_test/zone_config_system_tenant index 46a1741cc038..87ef8a172e90 100644 --- a/pkg/sql/logictest/testdata/logic_test/zone_config_system_tenant +++ b/pkg/sql/logictest/testdata/logic_test/zone_config_system_tenant @@ -1,6 +1,15 @@ # LogicTest: !3node-tenant-default-configs # Zone config logic tests that are only meant to work for the system tenant. +# Verify that the timeseries range has a zone config after bootstrap. It should +# only specify gc.ttlseconds, and everything should be implicitly inherited +# from the default range zone config. +query TT +SELECT target, raw_config_sql FROM [SHOW ZONE CONFIGURATIONS] WHERE target = 'RANGE timeseries' +---- +RANGE timeseries ALTER RANGE timeseries CONFIGURE ZONE USING + gc.ttlseconds = 14400 + statement ok CREATE TABLE t(); @@ -29,6 +38,7 @@ SELECT zone_id, target FROM crdb_internal.zones ORDER BY 1 11 TABLE system.public.lease 16 RANGE meta 17 RANGE system +18 RANGE timeseries 22 RANGE liveness 25 TABLE system.public.replication_constraint_stats 27 TABLE system.public.replication_stats @@ -194,8 +204,8 @@ ORDER BY start_key /Table/106 14400 /Table/107 14400 /Table/110 90001 -/Table/111 1 -/Table/112 1 +/Table/111 90001 +/Table/112 14400 subtest transactional_schemachanges diff --git a/pkg/sql/tests/system_table_test.go b/pkg/sql/tests/system_table_test.go index 0d01db593701..075bff3b7677 100644 --- a/pkg/sql/tests/system_table_test.go +++ b/pkg/sql/tests/system_table_test.go @@ -53,7 +53,7 @@ func TestInitialKeys(t *testing.T) { var nonDescKeys int if systemTenant { codec = keys.SystemSQLCodec - nonDescKeys = 16 + nonDescKeys = 17 } else { codec = keys.MakeSQLCodec(roachpb.MustMakeTenantID(5)) nonDescKeys = 8 diff --git a/pkg/sql/tests/testdata/initial_keys b/pkg/sql/tests/testdata/initial_keys index e9ccf3e3a787..a7d1396c85eb 100644 --- a/pkg/sql/tests/testdata/initial_keys +++ b/pkg/sql/tests/testdata/initial_keys @@ -1,6 +1,6 @@ initial-keys tenant=system ---- -130 keys: +131 keys: /Table/3/1/1/2/1 /Table/3/1/3/2/1 /Table/3/1/4/2/1 @@ -63,6 +63,7 @@ initial-keys tenant=system /Table/5/1/11/2/1 /Table/5/1/16/2/1 /Table/5/1/17/2/1 + /Table/5/1/18/2/1 /Table/5/1/22/2/1 /Table/5/1/25/2/1 /Table/5/1/27/2/1 From 0ae91a179163e74c4bbec6ecea88027155dea115 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Tue, 13 Aug 2024 17:13:02 -0400 Subject: [PATCH 2/3] upgrades: create a timeseries zone config during upgrade When upgrading to 24.3, the upgrade will create an explicit zone configuration for the timeseries range if one does not yet exist. It will match the zone config that is created during cluster bootstrap. The release note for this is in the previous commit. Release note: None --- .../settings/settings-for-tenants.txt | 2 +- docs/generated/settings/settings.html | 2 +- pkg/BUILD.bazel | 2 + pkg/clusterversion/cockroach_versions.go | 6 ++ pkg/sql/catalog/bootstrap/testdata/testdata | 10 +- pkg/sql/catalog/systemschema/system.go | 2 +- .../testdata/bootstrap_system | 2 +- .../testdata/bootstrap_tenant | 2 +- pkg/sql/logictest/BUILD.bazel | 2 + .../testdata/logic_test/crdb_internal_catalog | 2 +- .../logic_test/mixed_version_timeseries_range | 17 ++++ ...ed_version_timeseries_range_already_exists | 28 ++++++ .../cockroach-go-testserver-24.2/BUILD.bazel | 29 ++++++ .../generated_test.go | 93 +++++++++++++++++++ .../comparator_generated_test.go | 10 ++ pkg/upgrade/upgrades/BUILD.bazel | 1 + pkg/upgrade/upgrades/upgrades.go | 7 ++ .../v24_3_add_timeseries_zone_config.go | 59 ++++++++++++ 18 files changed, 265 insertions(+), 11 deletions(-) create mode 100644 pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range create mode 100644 pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range_already_exists create mode 100644 pkg/sql/logictest/tests/cockroach-go-testserver-24.2/BUILD.bazel create mode 100644 pkg/sql/logictest/tests/cockroach-go-testserver-24.2/generated_test.go create mode 100644 pkg/upgrade/upgrades/v24_3_add_timeseries_zone_config.go diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt index ac395ce6caec..f99306bfc433 100644 --- a/docs/generated/settings/settings-for-tenants.txt +++ b/docs/generated/settings/settings-for-tenants.txt @@ -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:///#/debug/tracez application trace.zipkin.collector string the address of a Zipkin instance to receive traces, as :. 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 '.' application +version version 1000024.2-upgrading-to-1000024.3-step-006 set the active cluster version in the format '.' application diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index 5dc82c72663b..d3f4a4474cd0 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -348,6 +348,6 @@
trace.span_registry.enabled
booleantrueif set, ongoing traces can be seen at https://<ui>/#/debug/tracezServerless/Dedicated/Self-Hosted
trace.zipkin.collector
stringthe address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.Serverless/Dedicated/Self-Hosted
ui.display_timezone
enumerationetc/utcthe timezone used to format timestamps in the ui [etc/utc = 0, america/new_york = 1]Serverless/Dedicated/Self-Hosted -
version
version1000024.2-upgrading-to-1000024.3-step-004set the active cluster version in the format '<major>.<minor>'Serverless/Dedicated/Self-Hosted +
version
version1000024.2-upgrading-to-1000024.3-step-006set the active cluster version in the format '<major>.<minor>'Serverless/Dedicated/Self-Hosted diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index 72fa02138002..188e4d38bc0a 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -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", @@ -1947,6 +1948,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", diff --git a/pkg/clusterversion/cockroach_versions.go b/pkg/clusterversion/cockroach_versions.go index 26448edac777..fa18777f1f7c 100644 --- a/pkg/clusterversion/cockroach_versions.go +++ b/pkg/clusterversion/cockroach_versions.go @@ -279,6 +279,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. @@ -351,6 +355,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. diff --git a/pkg/sql/catalog/bootstrap/testdata/testdata b/pkg/sql/catalog/bootstrap/testdata/testdata index d93450d6fc95..6843820f90c9 100644 --- a/pkg/sql/catalog/bootstrap/testdata/testdata +++ b/pkg/sql/catalog/bootstrap/testdata/testdata @@ -1,7 +1,7 @@ -system hash=6e9fc47c42475875a43765bbe4cff5d87f646b078e8d6bc69f239a8ae2dbb77b +system hash=2ae2763375bdffaed3ccc39f6c4f9cabd4aa28567c542cc8e6e150c3497e3b4b ---- [{"key":"8b"} -,{"key":"8b89898a89","value":"0312450a0673797374656d10011a250a0d0a0561646d696e1080101880100a0c0a04726f6f7410801018801012046e6f646518032200280140004a006a0a08d8843d100218002002"} +,{"key":"8b89898a89","value":"0312450a0673797374656d10011a250a0d0a0561646d696e1080101880100a0c0a04726f6f7410801018801012046e6f646518032200280140004a006a0a08d8843d100218002006"} ,{"key":"8b898b8a89","value":"030a8e030a0a64657363726970746f721803200128013a0042270a02696410011a0c08011040180030005014600020003000680070007800800100880100980100422f0a0a64657363726970746f7210021a0c08081000180030005011600020013000680070007800800100880100980100480352710a077072696d61727910011801220269642a0a64657363726970746f72300140004a10080010001a00200028003000380040005a0070027a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e00100e901000000000000000060026a210a0b0a0561646d696e102018200a0a0a04726f6f741020182012046e6f64651803800101880103980100b201130a077072696d61727910001a02696420012800b201240a1066616d5f325f64657363726970746f7210021a0a64657363726970746f7220022802b80103c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300d00300d80300e00300"} ,{"key":"8b898c8a89","value":"030ac7050a0575736572731804200128013a00422d0a08757365726e616d6510011a0c0807100018003000501960002000300068007000780080010088010098010042330a0e68617368656450617373776f726410021a0c0808100018003000501160002001300068007000780080010088010098010042320a066973526f6c6510031a0c08001000180030005010600020002a0566616c73653000680070007800800100880100980100422c0a07757365725f696410041a0c080c100018003000501a60002000300068007000780080010088010098010048055290010a077072696d617279100118012208757365726e616d652a0e68617368656450617373776f72642a066973526f6c652a07757365725f6964300140004a10080010001a00200028003000380040005a007002700370047a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00102e00100e90100000000000000005a740a1175736572735f757365725f69645f696478100218012207757365725f69643004380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00101e00100e901000000000000000060036a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651803800101880103980100b201240a077072696d61727910001a08757365726e616d651a07757365725f6964200120042804b2012c0a1466616d5f325f68617368656450617373776f726410021a0e68617368656450617373776f726420022802b2011c0a0c66616d5f335f6973526f6c6510031a066973526f6c6520032803b80104c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880303a80300b00300d00300d80300e00300"} ,{"key":"8b898d8a89","value":"030afd020a057a6f6e65731805200128013a0042270a02696410011a0c08011040180030005014600020003000680070007800800100880100980100422b0a06636f6e66696710021a0c080810001800300050116000200130006800700078008001008801009801004803526d0a077072696d61727910011801220269642a06636f6e666967300140004a10080010001a00200028003000380040005a0070027a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e00100e901000000000000000060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651803800101880103980100b201130a077072696d61727910001a02696420012800b2011c0a0c66616d5f325f636f6e66696710021a06636f6e66696720022802b80103c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300d00300d80300e00300"} @@ -65,7 +65,7 @@ system hash=6e9fc47c42475875a43765bbe4cff5d87f646b078e8d6bc69f239a8ae2dbb77b ,{"key":"8d89938a89","value":"03220308d804500158017800"} ,{"key":"8d89988a89","value":"031080808040188080808002220308901c2805500058007801"} ,{"key":"8d89998a89","value":"031080808040188080808002220308c0702805500058007801"} -,{"key":"8d899a8a89","value":"03220308c070500058007800"} +,{"key":"8d899a8a89","value":"03220308c070500158017800"} ,{"key":"8d899e8a89","value":"031080808040188080808002220308d8042805500058007801"} ,{"key":"8d89a18a89","value":"03220308d804500158017800"} ,{"key":"8d89a38a89","value":"03220308d804500158017800"} @@ -195,10 +195,10 @@ system hash=6e9fc47c42475875a43765bbe4cff5d87f646b078e8d6bc69f239a8ae2dbb77b ,{"key":"ca"} ] -tenant hash=11dc60832924e69d951e801ec37422e92e5ecc5702f9ad00b303e0262249f2f6 +tenant hash=17c52d00b75a99743d728d962c813d59843133b3181664f566183fc1aeece00f ---- [{"key":""} -,{"key":"8b89898a89","value":"0312450a0673797374656d10011a250a0d0a0561646d696e1080101880100a0c0a04726f6f7410801018801012046e6f646518032200280140004a006a0a08d8843d100218002002"} +,{"key":"8b89898a89","value":"0312450a0673797374656d10011a250a0d0a0561646d696e1080101880100a0c0a04726f6f7410801018801012046e6f646518032200280140004a006a0a08d8843d100218002006"} ,{"key":"8b898b8a89","value":"030a8e030a0a64657363726970746f721803200128013a0042270a02696410011a0c08011040180030005014600020003000680070007800800100880100980100422f0a0a64657363726970746f7210021a0c08081000180030005011600020013000680070007800800100880100980100480352710a077072696d61727910011801220269642a0a64657363726970746f72300140004a10080010001a00200028003000380040005a0070027a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e00100e901000000000000000060026a210a0b0a0561646d696e102018200a0a0a04726f6f741020182012046e6f64651803800101880103980100b201130a077072696d61727910001a02696420012800b201240a1066616d5f325f64657363726970746f7210021a0a64657363726970746f7220022802b80103c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300d00300d80300e00300"} ,{"key":"8b898c8a89","value":"030ac7050a0575736572731804200128013a00422d0a08757365726e616d6510011a0c0807100018003000501960002000300068007000780080010088010098010042330a0e68617368656450617373776f726410021a0c0808100018003000501160002001300068007000780080010088010098010042320a066973526f6c6510031a0c08001000180030005010600020002a0566616c73653000680070007800800100880100980100422c0a07757365725f696410041a0c080c100018003000501a60002000300068007000780080010088010098010048055290010a077072696d617279100118012208757365726e616d652a0e68617368656450617373776f72642a066973526f6c652a07757365725f6964300140004a10080010001a00200028003000380040005a007002700370047a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00102e00100e90100000000000000005a740a1175736572735f757365725f69645f696478100218012207757365725f69643004380140004a10080010001a00200028003000380040005a007a0408002000800100880100900103980100a20106080012001800a80100b20100ba0100c00100c80100d00101e00100e901000000000000000060036a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651803800101880103980100b201240a077072696d61727910001a08757365726e616d651a07757365725f6964200120042804b2012c0a1466616d5f325f68617368656450617373776f726410021a0e68617368656450617373776f726420022802b2011c0a0c66616d5f335f6973526f6c6510031a066973526f6c6520032803b80104c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880303a80300b00300d00300d80300e00300"} ,{"key":"8b898d8a89","value":"030afd020a057a6f6e65731805200128013a0042270a02696410011a0c08011040180030005014600020003000680070007800800100880100980100422b0a06636f6e66696710021a0c080810001800300050116000200130006800700078008001008801009801004803526d0a077072696d61727910011801220269642a06636f6e666967300140004a10080010001a00200028003000380040005a0070027a0408002000800100880100900104980101a20106080012001800a80100b20100ba0100c00100c80100d00101e00100e901000000000000000060026a250a0d0a0561646d696e10e00318e0030a0c0a04726f6f7410e00318e00312046e6f64651803800101880103980100b201130a077072696d61727910001a02696420012800b2011c0a0c66616d5f325f636f6e66696710021a06636f6e66696720022802b80103c20100e80100f2010408001200f801008002009202009a0200b20200b80200c0021dc80200e00200800300880302a80300b00300d00300d80300e00300"} diff --git a/pkg/sql/catalog/systemschema/system.go b/pkg/sql/catalog/systemschema/system.go index 879c3ff693ba..a7e074bb558c 100644 --- a/pkg/sql/catalog/systemschema/system.go +++ b/pkg/sql/catalog/systemschema/system.go @@ -1227,7 +1227,7 @@ const SystemDatabaseName = catconstants.SystemDatabaseName // release version). // // NB: Don't set this to clusterversion.Latest; use a specific version instead. -var SystemDatabaseSchemaBootstrapVersion = clusterversion.V24_3_Start.Version() +var SystemDatabaseSchemaBootstrapVersion = clusterversion.V24_3_AddTimeseriesZoneConfig.Version() // MakeSystemDatabaseDesc constructs a copy of the system database // descriptor. diff --git a/pkg/sql/catalog/systemschema_test/testdata/bootstrap_system b/pkg/sql/catalog/systemschema_test/testdata/bootstrap_system index d19f2b4e7171..abad86c3336b 100644 --- a/pkg/sql/catalog/systemschema_test/testdata/bootstrap_system +++ b/pkg/sql/catalog/systemschema_test/testdata/bootstrap_system @@ -642,7 +642,7 @@ schema_telemetry ---- {"database":{"name":"defaultdb","id":100,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"2048"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"root","version":3},"schemas":{"public":{"id":101}},"defaultPrivileges":{}}} {"database":{"name":"postgres","id":102,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"2048"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"root","version":3},"schemas":{"public":{"id":103}},"defaultPrivileges":{}}} -{"database":{"name":"system","id":1,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2048","withGrantOption":"2048"},{"userProto":"root","privileges":"2048","withGrantOption":"2048"}],"ownerProto":"node","version":3},"systemDatabaseSchemaVersion":{"majorVal":1000024,"minorVal":2,"internal":2}}} +{"database":{"name":"system","id":1,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2048","withGrantOption":"2048"},{"userProto":"root","privileges":"2048","withGrantOption":"2048"}],"ownerProto":"node","version":3},"systemDatabaseSchemaVersion":{"majorVal":1000024,"minorVal":2,"internal":6}}} {"table":{"name":"comments","id":24,"version":"1","modificationTime":{},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"type","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"object_id","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"sub_id","id":3,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"comment","id":4,"type":{"family":"StringFamily","oid":25}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["type","object_id","sub_id"],"columnIds":[1,2,3]},{"name":"fam_4_comment","id":4,"columnNames":["comment"],"columnIds":[4],"defaultColumnId":4}],"nextFamilyId":5,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["type","object_id","sub_id"],"keyColumnDirections":["ASC","ASC","ASC"],"storeColumnNames":["comment"],"keyColumnIds":[1,2,3],"storeColumnIds":[4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"public","privileges":"32"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":3},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} {"table":{"name":"database_role_settings","id":44,"version":"1","modificationTime":{},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"database_id","id":1,"type":{"family":"OidFamily","oid":26}},{"name":"role_name","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"settings","id":3,"type":{"family":"ArrayFamily","arrayElemType":"StringFamily","oid":1009,"arrayContents":{"family":"StringFamily","oid":25}}},{"name":"role_id","id":4,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["database_id","role_name","settings","role_id"],"columnIds":[1,2,3,4]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["database_id","role_name"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["settings","role_id"],"keyColumnIds":[1,2],"storeColumnIds":[3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"database_role_settings_database_id_role_id_key","id":2,"unique":true,"version":3,"keyColumnNames":["database_id","role_id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["settings"],"keyColumnIds":[1,4],"keySuffixColumnIds":[2],"storeColumnIds":[3],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":3},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} {"table":{"name":"descriptor","id":3,"version":"1","modificationTime":{},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"descriptor","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id"],"columnIds":[1]},{"name":"fam_2_descriptor","id":2,"columnNames":["descriptor"],"columnIds":[2],"defaultColumnId":2}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["descriptor"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":3},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} diff --git a/pkg/sql/catalog/systemschema_test/testdata/bootstrap_tenant b/pkg/sql/catalog/systemschema_test/testdata/bootstrap_tenant index d19f2b4e7171..abad86c3336b 100644 --- a/pkg/sql/catalog/systemschema_test/testdata/bootstrap_tenant +++ b/pkg/sql/catalog/systemschema_test/testdata/bootstrap_tenant @@ -642,7 +642,7 @@ schema_telemetry ---- {"database":{"name":"defaultdb","id":100,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"2048"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"root","version":3},"schemas":{"public":{"id":101}},"defaultPrivileges":{}}} {"database":{"name":"postgres","id":102,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2","withGrantOption":"2"},{"userProto":"public","privileges":"2048"},{"userProto":"root","privileges":"2","withGrantOption":"2"}],"ownerProto":"root","version":3},"schemas":{"public":{"id":103}},"defaultPrivileges":{}}} -{"database":{"name":"system","id":1,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2048","withGrantOption":"2048"},{"userProto":"root","privileges":"2048","withGrantOption":"2048"}],"ownerProto":"node","version":3},"systemDatabaseSchemaVersion":{"majorVal":1000024,"minorVal":2,"internal":2}}} +{"database":{"name":"system","id":1,"modificationTime":{"wallTime":"0"},"version":"1","privileges":{"users":[{"userProto":"admin","privileges":"2048","withGrantOption":"2048"},{"userProto":"root","privileges":"2048","withGrantOption":"2048"}],"ownerProto":"node","version":3},"systemDatabaseSchemaVersion":{"majorVal":1000024,"minorVal":2,"internal":6}}} {"table":{"name":"comments","id":24,"version":"1","modificationTime":{},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"type","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"object_id","id":2,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"sub_id","id":3,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"comment","id":4,"type":{"family":"StringFamily","oid":25}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["type","object_id","sub_id"],"columnIds":[1,2,3]},{"name":"fam_4_comment","id":4,"columnNames":["comment"],"columnIds":[4],"defaultColumnId":4}],"nextFamilyId":5,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["type","object_id","sub_id"],"keyColumnDirections":["ASC","ASC","ASC"],"storeColumnNames":["comment"],"keyColumnIds":[1,2,3],"storeColumnIds":[4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"public","privileges":"32"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":3},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} {"table":{"name":"database_role_settings","id":44,"version":"1","modificationTime":{},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"database_id","id":1,"type":{"family":"OidFamily","oid":26}},{"name":"role_name","id":2,"type":{"family":"StringFamily","oid":25}},{"name":"settings","id":3,"type":{"family":"ArrayFamily","arrayElemType":"StringFamily","oid":1009,"arrayContents":{"family":"StringFamily","oid":25}}},{"name":"role_id","id":4,"type":{"family":"OidFamily","oid":26}}],"nextColumnId":5,"families":[{"name":"primary","columnNames":["database_id","role_name","settings","role_id"],"columnIds":[1,2,3,4]}],"nextFamilyId":1,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["database_id","role_name"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["settings","role_id"],"keyColumnIds":[1,2],"storeColumnIds":[3,4],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":2},"indexes":[{"name":"database_role_settings_database_id_role_id_key","id":2,"unique":true,"version":3,"keyColumnNames":["database_id","role_id"],"keyColumnDirections":["ASC","ASC"],"storeColumnNames":["settings"],"keyColumnIds":[1,4],"keySuffixColumnIds":[2],"storeColumnIds":[3],"foreignKey":{},"interleave":{},"partitioning":{},"sharded":{},"geoConfig":{},"constraintId":1}],"nextIndexId":3,"privileges":{"users":[{"userProto":"admin","privileges":"480","withGrantOption":"480"},{"userProto":"root","privileges":"480","withGrantOption":"480"}],"ownerProto":"node","version":3},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":3}} {"table":{"name":"descriptor","id":3,"version":"1","modificationTime":{},"parentId":1,"unexposedParentSchemaId":29,"columns":[{"name":"id","id":1,"type":{"family":"IntFamily","width":64,"oid":20}},{"name":"descriptor","id":2,"type":{"family":"BytesFamily","oid":17},"nullable":true}],"nextColumnId":3,"families":[{"name":"primary","columnNames":["id"],"columnIds":[1]},{"name":"fam_2_descriptor","id":2,"columnNames":["descriptor"],"columnIds":[2],"defaultColumnId":2}],"nextFamilyId":3,"primaryIndex":{"name":"primary","id":1,"unique":true,"version":4,"keyColumnNames":["id"],"keyColumnDirections":["ASC"],"storeColumnNames":["descriptor"],"keyColumnIds":[1],"storeColumnIds":[2],"foreignKey":{},"interleave":{},"partitioning":{},"encodingType":1,"sharded":{},"geoConfig":{},"constraintId":1},"nextIndexId":2,"privileges":{"users":[{"userProto":"admin","privileges":"32","withGrantOption":"32"},{"userProto":"root","privileges":"32","withGrantOption":"32"}],"ownerProto":"node","version":3},"nextMutationId":1,"formatVersion":3,"replacementOf":{"time":{}},"createAsOfTime":{},"nextConstraintId":2}} diff --git a/pkg/sql/logictest/BUILD.bazel b/pkg/sql/logictest/BUILD.bazel index 35166bae06fd..a2c8f4a7510e 100644 --- a/pkg/sql/logictest/BUILD.bazel +++ b/pkg/sql/logictest/BUILD.bazel @@ -38,7 +38,9 @@ filegroup( }), visibility = [ "//pkg/ccl/logictestccl/tests/cockroach-go-testserver-24.1:__pkg__", + "//pkg/ccl/logictestccl/tests/cockroach-go-testserver-24.2:__pkg__", "//pkg/sql/logictest/tests/cockroach-go-testserver-24.1:__pkg__", + "//pkg/sql/logictest/tests/cockroach-go-testserver-24.2:__pkg__", ], ) diff --git a/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog b/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog index fa48d8c7a3d2..44605fe6278e 100644 --- a/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog +++ b/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog @@ -105,7 +105,7 @@ skipif config local-mixed-24.2 query IT SELECT id, strip_volatile(descriptor) FROM crdb_internal.kv_catalog_descriptor ORDER BY id ---- -1 {"database": {"id": 1, "name": "system", "privileges": {"ownerProto": "node", "users": [{"privileges": "2048", "userProto": "admin", "withGrantOption": "2048"}, {"privileges": "2048", "userProto": "root", "withGrantOption": "2048"}], "version": 3}, "systemDatabaseSchemaVersion": {"internal": 2, "majorVal": 1000024, "minorVal": 2}, "version": "1"}} +1 {"database": {"id": 1, "name": "system", "privileges": {"ownerProto": "node", "users": [{"privileges": "2048", "userProto": "admin", "withGrantOption": "2048"}, {"privileges": "2048", "userProto": "root", "withGrantOption": "2048"}], "version": 3}, "systemDatabaseSchemaVersion": {"internal": 6, "majorVal": 1000024, "minorVal": 2}, "version": "1"}} 3 {"table": {"columns": [{"id": 1, "name": "id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "descriptor", "nullable": true, "type": {"family": "BytesFamily", "oid": 17}}], "formatVersion": 3, "id": 3, "name": "descriptor", "nextColumnId": 3, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 1, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [1], "keyColumnNames": ["id"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [2], "storeColumnNames": ["descriptor"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "admin", "withGrantOption": "32"}, {"privileges": "32", "userProto": "root", "withGrantOption": "32"}], "version": 3}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} 4 {"table": {"columns": [{"id": 1, "name": "username", "type": {"family": "StringFamily", "oid": 25}}, {"id": 2, "name": "hashedPassword", "nullable": true, "type": {"family": "BytesFamily", "oid": 17}}, {"defaultExpr": "false", "id": 3, "name": "isRole", "type": {"oid": 16}}, {"id": 4, "name": "user_id", "type": {"family": "OidFamily", "oid": 26}}], "formatVersion": 3, "id": 4, "indexes": [{"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 2, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [4], "keyColumnNames": ["user_id"], "keySuffixColumnIds": [1], "name": "users_user_id_idx", "partitioning": {}, "sharded": {}, "unique": true, "version": 3}], "name": "users", "nextColumnId": 5, "nextConstraintId": 3, "nextIndexId": 3, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 2, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [1], "keyColumnNames": ["username"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [2, 3, 4], "storeColumnNames": ["hashedPassword", "isRole", "user_id"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 3}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "2"}} 5 {"table": {"columns": [{"id": 1, "name": "id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "config", "nullable": true, "type": {"family": "BytesFamily", "oid": 17}}], "formatVersion": 3, "id": 5, "name": "zones", "nextColumnId": 3, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "parentId": 1, "primaryIndex": {"constraintId": 1, "encodingType": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "keyColumnDirections": ["ASC"], "keyColumnIds": [1], "keyColumnNames": ["id"], "name": "primary", "partitioning": {}, "sharded": {}, "storeColumnIds": [2], "storeColumnNames": ["config"], "unique": true, "version": 4}, "privileges": {"ownerProto": "node", "users": [{"privileges": "480", "userProto": "admin", "withGrantOption": "480"}, {"privileges": "480", "userProto": "root", "withGrantOption": "480"}], "version": 3}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 29, "version": "1"}} diff --git a/pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range b/pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range new file mode 100644 index 000000000000..7d512f150e49 --- /dev/null +++ b/pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range @@ -0,0 +1,17 @@ +# LogicTest: cockroach-go-testserver-24.2 + +query TT +SELECT target, raw_config_sql FROM [SHOW ZONE CONFIGURATIONS] WHERE target = 'RANGE timeseries' +---- + +upgrade all + +statement ok +SET CLUSTER SETTING version = crdb_internal.node_executable_version() + +# The zone config should exist after upgrading. +query TT +SELECT target, raw_config_sql FROM [SHOW ZONE CONFIGURATIONS] WHERE target = 'RANGE timeseries' +---- +RANGE timeseries ALTER RANGE timeseries CONFIGURE ZONE USING + gc.ttlseconds = 14400 diff --git a/pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range_already_exists b/pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range_already_exists new file mode 100644 index 000000000000..ec4ae9d4bc12 --- /dev/null +++ b/pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range_already_exists @@ -0,0 +1,28 @@ +# LogicTest: cockroach-go-testserver-24.2 + +# This test verifies that if the timeseries range already has a zone config +# before upgrading to the current version, then that zone config is preserved +# during the upgrade. + +statement ok +ALTER RANGE timeseries CONFIGURE ZONE USING gc.ttlseconds = 12345, num_replicas = 5 + +query TT +SELECT target, raw_config_sql FROM [SHOW ZONE CONFIGURATIONS] WHERE target = 'RANGE timeseries' +---- +RANGE timeseries ALTER RANGE timeseries CONFIGURE ZONE USING + gc.ttlseconds = 12345, + num_replicas = 5 + +upgrade all + +statement ok +SET CLUSTER SETTING version = crdb_internal.node_executable_version() + +# The zone config should exist after upgrading. +query TT +SELECT target, raw_config_sql FROM [SHOW ZONE CONFIGURATIONS] WHERE target = 'RANGE timeseries' +---- +RANGE timeseries ALTER RANGE timeseries CONFIGURE ZONE USING + gc.ttlseconds = 12345, + num_replicas = 5 diff --git a/pkg/sql/logictest/tests/cockroach-go-testserver-24.2/BUILD.bazel b/pkg/sql/logictest/tests/cockroach-go-testserver-24.2/BUILD.bazel new file mode 100644 index 000000000000..2f4a8926e3ea --- /dev/null +++ b/pkg/sql/logictest/tests/cockroach-go-testserver-24.2/BUILD.bazel @@ -0,0 +1,29 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_test") + +go_test( + name = "cockroach-go-testserver-24_2_test", + size = "enormous", + srcs = ["generated_test.go"], + data = [ + "//c-deps:libgeos", # keep + "//pkg/cmd/cockroach-short", # keep + "//pkg/sql/logictest:cockroach_predecessor_version", # keep + "//pkg/sql/logictest:testdata", # keep + ], + exec_properties = {"test.Pool": "large"}, + shard_count = 2, + tags = ["cpu:2"], + deps = [ + "//pkg/base", + "//pkg/build/bazel", + "//pkg/security/securityassets", + "//pkg/security/securitytest", + "//pkg/server", + "//pkg/sql/logictest", + "//pkg/testutils/serverutils", + "//pkg/testutils/skip", + "//pkg/testutils/testcluster", + "//pkg/util/leaktest", + "//pkg/util/randutil", + ], +) diff --git a/pkg/sql/logictest/tests/cockroach-go-testserver-24.2/generated_test.go b/pkg/sql/logictest/tests/cockroach-go-testserver-24.2/generated_test.go new file mode 100644 index 000000000000..68604faa4f59 --- /dev/null +++ b/pkg/sql/logictest/tests/cockroach-go-testserver-24.2/generated_test.go @@ -0,0 +1,93 @@ +// Copyright 2022 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. + +// Code generated by generate-logictest, DO NOT EDIT. + +package testcockroach_go_testserver_242 + +import ( + "os" + "path/filepath" + "testing" + + "github.com/cockroachdb/cockroach/pkg/base" + "github.com/cockroachdb/cockroach/pkg/build/bazel" + "github.com/cockroachdb/cockroach/pkg/security/securityassets" + "github.com/cockroachdb/cockroach/pkg/security/securitytest" + "github.com/cockroachdb/cockroach/pkg/server" + "github.com/cockroachdb/cockroach/pkg/sql/logictest" + "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" + "github.com/cockroachdb/cockroach/pkg/testutils/skip" + "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" + "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/cockroachdb/cockroach/pkg/util/randutil" +) + +const configIdx = 21 + +var logicTestDir string + +func init() { + if bazel.BuiltWithBazel() { + var err error + logicTestDir, err = bazel.Runfile("pkg/sql/logictest/testdata/logic_test") + if err != nil { + panic(err) + } + } else { + logicTestDir = "../../../../sql/logictest/testdata/logic_test" + } +} + +func TestMain(m *testing.M) { + securityassets.SetLoader(securitytest.EmbeddedAssets) + randutil.SeedForTests() + serverutils.InitTestServerFactory(server.TestServerFactory) + serverutils.InitTestClusterFactory(testcluster.TestClusterFactory) + + defer serverutils.TestingSetDefaultTenantSelectionOverride( + base.TestIsForStuffThatShouldWorkWithSecondaryTenantsButDoesntYet(76378), + )() + + os.Exit(m.Run()) +} + +func runLogicTest(t *testing.T, file string) { + skip.UnderDeadlock(t, "times out and/or hangs") + logictest.RunLogicTest(t, logictest.TestServerArgs{}, configIdx, filepath.Join(logicTestDir, file)) +} + +// TestLogic_tmp runs any tests that are prefixed with "_", in which a dedicated +// test is not generated for. This allows developers to create and run temporary +// test files that are not checked into the repository, without repeatedly +// regenerating and reverting changes to this file, generated_test.go. +// +// TODO(mgartner): Add file filtering so that individual files can be run, +// instead of all files with the "_" prefix. +func TestLogic_tmp(t *testing.T) { + defer leaktest.AfterTest(t)() + var glob string + glob = filepath.Join(logicTestDir, "_*") + logictest.RunLogicTests(t, logictest.TestServerArgs{}, configIdx, glob) +} + +func TestLogic_mixed_version_timeseries_range( + t *testing.T, +) { + defer leaktest.AfterTest(t)() + runLogicTest(t, "mixed_version_timeseries_range") +} + +func TestLogic_mixed_version_timeseries_range_already_exists( + t *testing.T, +) { + defer leaktest.AfterTest(t)() + runLogicTest(t, "mixed_version_timeseries_range_already_exists") +} diff --git a/pkg/sql/schemachanger/comparator_generated_test.go b/pkg/sql/schemachanger/comparator_generated_test.go index 1dc8914aa0cf..a89a2ea609a4 100644 --- a/pkg/sql/schemachanger/comparator_generated_test.go +++ b/pkg/sql/schemachanger/comparator_generated_test.go @@ -1033,6 +1033,16 @@ func TestSchemaChangeComparator_mixed_version_can_login(t *testing.T) { var logicTestFile = "pkg/sql/logictest/testdata/logic_test/mixed_version_can_login" runSchemaChangeComparatorTest(t, logicTestFile) } +func TestSchemaChangeComparator_mixed_version_timeseries_range(t *testing.T) { + defer leaktest.AfterTest(t)() + var logicTestFile = "pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range" + runSchemaChangeComparatorTest(t, logicTestFile) +} +func TestSchemaChangeComparator_mixed_version_timeseries_range_already_exists(t *testing.T) { + defer leaktest.AfterTest(t)() + var logicTestFile = "pkg/sql/logictest/testdata/logic_test/mixed_version_timeseries_range_already_exists" + runSchemaChangeComparatorTest(t, logicTestFile) +} func TestSchemaChangeComparator_mixed_version_upgrade_preserve_ttl(t *testing.T) { defer leaktest.AfterTest(t)() var logicTestFile = "pkg/sql/logictest/testdata/logic_test/mixed_version_upgrade_preserve_ttl" diff --git a/pkg/upgrade/upgrades/BUILD.bazel b/pkg/upgrade/upgrades/BUILD.bazel index e0d39e1eb1ad..26077901638b 100644 --- a/pkg/upgrade/upgrades/BUILD.bazel +++ b/pkg/upgrade/upgrades/BUILD.bazel @@ -18,6 +18,7 @@ go_library( "v24_2_delete_version_tenant_settings.go", "v24_2_tenant_rates.go", "v24_2_tenant_system_tables.go", + "v24_3_add_timeseries_zone_config.go", ], importpath = "github.com/cockroachdb/cockroach/pkg/upgrade/upgrades", visibility = ["//visibility:public"], diff --git a/pkg/upgrade/upgrades/upgrades.go b/pkg/upgrade/upgrades/upgrades.go index 723cc9ae7f6e..c68a9597abf6 100644 --- a/pkg/upgrade/upgrades/upgrades.go +++ b/pkg/upgrade/upgrades/upgrades.go @@ -100,6 +100,13 @@ var upgrades = []upgradebase.Upgrade{ newFirstUpgrade(clusterversion.V24_3_Start.Version()), + upgrade.NewSystemUpgrade( + "create a zone config for the timeseries range if one does not exist already", + clusterversion.V24_3_AddTimeseriesZoneConfig.Version(), + addTimeseriesZoneConfig, + upgrade.RestoreActionNotRequired("this zone config isn't necessary for restore"), + ), + // Note: when starting a new release version, the first upgrade (for // Vxy_zStart) must be a newFirstUpgrade. Keep this comment at the bottom. } diff --git a/pkg/upgrade/upgrades/v24_3_add_timeseries_zone_config.go b/pkg/upgrade/upgrades/v24_3_add_timeseries_zone_config.go new file mode 100644 index 000000000000..4af675b9b7d2 --- /dev/null +++ b/pkg/upgrade/upgrades/v24_3_add_timeseries_zone_config.go @@ -0,0 +1,59 @@ +// Copyright 2024 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 upgrades + +import ( + "context" + + "github.com/cockroachdb/cockroach/pkg/clusterversion" + "github.com/cockroachdb/cockroach/pkg/sql/isql" + "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" + "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" + "github.com/cockroachdb/cockroach/pkg/upgrade" + "github.com/cockroachdb/errors" +) + +// addTimeseriesZoneConfig creates a zone configuration for the timeseries +// range if one does not exist already. It will match the zone config that is +// created during bootstrap. +func addTimeseriesZoneConfig( + ctx context.Context, cs clusterversion.ClusterVersion, d upgrade.SystemDeps, +) error { + err := d.DB.Txn(ctx, func(ctx context.Context, txn isql.Txn) error { + row, err := txn.QueryRowEx( + ctx, "check-timeseries-zone-config-exists", txn.KV(), + sessiondata.NodeUserSessionDataOverride, + "SELECT count(*) = 1 FROM [SHOW ZONE CONFIGURATIONS] WHERE target = 'RANGE timeseries'", + ) + if err != nil { + return err + } + hasTimeseriesRange, ok := tree.AsDBool(row[0]) + if !ok { + return errors.New("unexpected result from SHOW ZONE CONFIGURATIONS") + } + if hasTimeseriesRange { + return nil + } + if _, err := txn.ExecEx( + ctx, "add-timeseries-zone-config", txn.KV(), + sessiondata.NodeUserSessionDataOverride, + "ALTER RANGE timeseries CONFIGURE ZONE USING gc.ttlseconds = 14400", + ); err != nil { + return err + } + return nil + }) + if err != nil { + return err + } + return nil +} From f9e0f166e30d9d3cead07391e0edd12cf99b3d32 Mon Sep 17 00:00:00 2001 From: Marcus Gartner Date: Thu, 15 Aug 2024 10:48:48 -0400 Subject: [PATCH 3/3] sql/parser: only retain scanned SQL comments when necessary 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 --- pkg/sql/crdb_internal.go | 2 +- pkg/sql/parser/parse.go | 33 +++++++++++++++++++++++++-------- pkg/sql/scanner/scan.go | 26 ++++++++++++++++++++------ 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/pkg/sql/crdb_internal.go b/pkg/sql/crdb_internal.go index fbd1cb650590..dfd7b099d764 100644 --- a/pkg/sql/crdb_internal.go +++ b/pkg/sql/crdb_internal.go @@ -2832,7 +2832,7 @@ func populateQueriesTable( // formatActiveQuery formats a serverpb.ActiveQuery by interpolating its // placeholders within the string. func formatActiveQuery(query serverpb.ActiveQuery) string { - parsed, parseErr := parser.ParseOne(query.Sql) + parsed, parseErr := parser.ParseOneRetainComments(query.Sql) if parseErr != nil { // If we failed to interpolate, rather than give up just send out the // SQL without interpolated placeholders. Hallelujah! diff --git a/pkg/sql/parser/parse.go b/pkg/sql/parser/parse.go index 1f351296f706..1a72a652b45f 100644 --- a/pkg/sql/parser/parse.go +++ b/pkg/sql/parser/parse.go @@ -68,19 +68,19 @@ func NakedIntTypeFromDefaultIntSize(defaultIntSize int32) *types.T { // Parse parses the sql and returns a list of statements. func (p *Parser) Parse(sql string) (statements.Statements, error) { - return p.parseWithDepth(1, sql, defaultNakedIntType) + return p.parseWithDepth(1, sql, defaultNakedIntType, discardComments) } // ParseWithInt parses a sql statement string and returns a list of // Statements. The INT token will result in the specified TInt type. func (p *Parser) ParseWithInt(sql string, nakedIntType *types.T) (statements.Statements, error) { - return p.parseWithDepth(1, sql, nakedIntType) + return p.parseWithDepth(1, sql, nakedIntType, discardComments) } func (p *Parser) parseOneWithInt( - sql string, nakedIntType *types.T, + sql string, nakedIntType *types.T, comments commentsMode, ) (statements.Statement[tree.Statement], error) { - stmts, err := p.parseWithDepth(1, sql, nakedIntType) + stmts, err := p.parseWithDepth(1, sql, nakedIntType, comments) if err != nil { return statements.Statement[tree.Statement]{}, err } @@ -144,11 +144,21 @@ func (p *Parser) scanOneStmt() (sql string, tokens []sqlSymType, done bool) { } } +type commentsMode bool + +const ( + retainComments commentsMode = true + discardComments commentsMode = false +) + func (p *Parser) parseWithDepth( - depth int, sql string, nakedIntType *types.T, + depth int, sql string, nakedIntType *types.T, cm commentsMode, ) (statements.Statements, error) { stmts := statements.Statements(p.stmtBuf[:0]) p.scanner.Init(sql) + if cm == retainComments { + p.scanner.RetainComments() + } defer p.scanner.Cleanup() for { sql, tokens, done := p.scanOneStmt() @@ -232,26 +242,33 @@ func Parse(sql string) (statements.Statements, error) { // Statements. The INT token will result in the specified TInt type. func ParseWithInt(sql string, nakedIntType *types.T) (statements.Statements, error) { var p Parser - return p.parseWithDepth(1, sql, nakedIntType) + return p.parseWithDepth(1, sql, nakedIntType, discardComments) } // ParseOne parses a sql statement string, ensuring that it contains only a // single statement, and returns that Statement. ParseOne will always // interpret the INT and SERIAL types as 64-bit types, since this is // used in various internal-execution paths where we might receive -// bits of SQL from other nodes. In general,earwe expect that all +// bits of SQL from other nodes. In general, we expect that all // user-generated SQL has been run through the ParseWithInt() function. func ParseOne(sql string) (statements.Statement[tree.Statement], error) { return ParseOneWithInt(sql, defaultNakedIntType) } +// ParseOneRetainComments is similar to ParseOne, but it retains scanned +// comments in the returned statement's Comment field. +func ParseOneRetainComments(sql string) (statements.Statement[tree.Statement], error) { + var p Parser + return p.parseOneWithInt(sql, defaultNakedIntType, retainComments) +} + // ParseOneWithInt is similar to ParseOn but interprets the INT and SERIAL // types as the provided integer type. func ParseOneWithInt( sql string, nakedIntType *types.T, ) (statements.Statement[tree.Statement], error) { var p Parser - return p.parseOneWithInt(sql, nakedIntType) + return p.parseOneWithInt(sql, nakedIntType, discardComments) } // ParseQualifiedTableName parses a possibly qualified table name. The diff --git a/pkg/sql/scanner/scan.go b/pkg/sql/scanner/scan.go index 2b1e53876f70..547550cdcc3b 100644 --- a/pkg/sql/scanner/scan.go +++ b/pkg/sql/scanner/scan.go @@ -69,6 +69,9 @@ type Scanner struct { // quoted. Used to distinguish between quoted and non-quoted in // Inspect. quoted bool + // retainComments indicates that comments should be collected in the + // Comments field. If it is false, they are discarded. + retainComments bool } // SQLScanner is a scanner with a SQL specific scan function @@ -88,10 +91,18 @@ func (s *Scanner) Pos() int { // Init initializes a new Scanner that will process str. func (s *Scanner) Init(str string) { - s.in = str - s.pos = 0 - // Preallocate some buffer space for identifiers etc. - s.bytesPrealloc = make([]byte, len(str)) + *s = Scanner{ + in: str, + pos: 0, + // Preallocate some buffer space for identifiers etc. + bytesPrealloc: make([]byte, len(str)), + } +} + +// RetainComments instructs the scanner to collect SQL comments in the Comments +// field. +func (s *Scanner) RetainComments() { + s.retainComments = true } // Cleanup is used to avoid holding on to memory unnecessarily (for the cases @@ -99,6 +110,7 @@ func (s *Scanner) Init(str string) { func (s *Scanner) Cleanup() { s.bytesPrealloc = nil s.Comments = nil + s.retainComments = false } func (s *Scanner) allocBytes(length int) []byte { @@ -529,8 +541,10 @@ func (s *Scanner) skipWhitespace(lval ScanSymType, allowComments bool) (newline, if present, cok := s.ScanComment(lval); !cok { return false, false } else if present { - // Mark down the comments that we found. - s.Comments = append(s.Comments, s.in[startPos:s.pos]) + if s.retainComments { + // Mark down the comments that we found. + s.Comments = append(s.Comments, s.in[startPos:s.pos]) + } continue } }