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/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/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/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..6843820f90c9 100644 --- a/pkg/sql/catalog/bootstrap/testdata/testdata +++ b/pkg/sql/catalog/bootstrap/testdata/testdata @@ -1,7 +1,7 @@ -system hash=3d3210258c9ec86c5b1aa619be83379f5a23b5da269ec9f90fa68c5c6f87fc4f +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,6 +65,7 @@ system hash=3d3210258c9ec86c5b1aa619be83379f5a23b5da269ec9f90fa68c5c6f87fc4f ,{"key":"8d89938a89","value":"03220308d804500158017800"} ,{"key":"8d89988a89","value":"031080808040188080808002220308901c2805500058007801"} ,{"key":"8d89998a89","value":"031080808040188080808002220308c0702805500058007801"} +,{"key":"8d899a8a89","value":"03220308c070500158017800"} ,{"key":"8d899e8a89","value":"031080808040188080808002220308d8042805500058007801"} ,{"key":"8d89a18a89","value":"03220308d804500158017800"} ,{"key":"8d89a38a89","value":"03220308d804500158017800"} @@ -194,10 +195,10 @@ system hash=3d3210258c9ec86c5b1aa619be83379f5a23b5da269ec9f90fa68c5c6f87fc4f ,{"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/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/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 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/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/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/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/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 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 +}