From d179047fa89bb8082a23a62b6275394b87b4cb61 Mon Sep 17 00:00:00 2001 From: Andrei Matei Date: Fri, 25 Oct 2019 15:39:53 -0400 Subject: [PATCH] settings/cluster: introducing the 19.2 cluster version This is not a backport; it's original work on the release-19.2 branch. The corresponding work on master is #41931. I've had to skip a test because it was validating that we've removed all the versions introduced before 19.1, since they're now "always active". Work to remove those versions is in progress on master. Release note: None --- docs/generated/settings/settings.html | 2 +- pkg/server/version_cluster_test.go | 28 +++++++++++++++++-- pkg/settings/cluster/cockroach_versions.go | 6 ++++ .../cluster/cockroach_versions_test.go | 2 ++ pkg/settings/cluster/versionkey_string.go | 5 ++-- .../testdata/logic_test/crdb_internal | 4 +-- 6 files changed, 40 insertions(+), 7 deletions(-) diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index 9877dd108cb9..2da2c15d4922 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -134,6 +134,6 @@ trace.debug.enablebooleanfalseif set, traces for recent requests can be seen in the /debug page trace.lightstep.tokenstringif set, traces go to Lightstep using this token trace.zipkin.collectorstringif set, traces go to the given Zipkin instance (example: '127.0.0.1:9411'); ignored if trace.lightstep.token is set -versioncustom validation19.1-11set the active cluster version in the format '.' +versioncustom validation19.2set the active cluster version in the format '.' diff --git a/pkg/server/version_cluster_test.go b/pkg/server/version_cluster_test.go index ae27d84d29eb..137499c56a39 100644 --- a/pkg/server/version_cluster_test.go +++ b/pkg/server/version_cluster_test.go @@ -134,11 +134,35 @@ func setupMixedCluster( } // Prev returns the previous version of the given version. -// eg. prev(2.0) = 1.0, prev(2.1) == 2.0, prev(2.1-5) == 2.1. +// eg. prev(20.1) = 19.2, prev(19.2) = 19.1, prev(19.1) = 2.1, +// prev(2.0) = 1.0, prev(2.1) == 2.0, prev(2.1-5) == 2.1. func prev(version roachpb.Version) roachpb.Version { if version.Unstable != 0 { return roachpb.Version{Major: version.Major, Minor: version.Minor} - } else if version.Minor != 0 { + } + + v19_1 := roachpb.Version{Major: 19, Minor: 1} + + if v19_1.Less(version) { + if version.Minor > 1 { + return roachpb.Version{Major: version.Major, Minor: version.Minor - 1} + } + // Here we assume that there's going to only be 2 releases per year. + // Otherwise we'd need to keep some history of what releases we've had. + return roachpb.Version{Major: version.Major - 1, Minor: 2} + } + + if version == v19_1 { + return roachpb.Version{Major: 2, Minor: 1} + } + + // Logic for versions below 19.1. + + if version.Major > 2 { + log.Fatalf(context.TODO(), "can't compute previous version for %s", version) + } + + if version.Minor != 0 { return roachpb.Version{Major: version.Major} } else { // version will be at least 2.0-X, so it's safe to set new Major to be version.Major-1. diff --git a/pkg/settings/cluster/cockroach_versions.go b/pkg/settings/cluster/cockroach_versions.go index 249c84c4e4cf..97ed249b6481 100644 --- a/pkg/settings/cluster/cockroach_versions.go +++ b/pkg/settings/cluster/cockroach_versions.go @@ -46,6 +46,7 @@ const ( VersionAtomicChangeReplicas VersionTableDescModificationTimeFromMVCC VersionPartitionedBackup + Version19_2 // Add new versions here (step one of two). @@ -551,6 +552,11 @@ var versionsSingleton = keyedVersions([]keyedVersion{ Key: VersionPartitionedBackup, Version: roachpb.Version{Major: 19, Minor: 1, Unstable: 11}, }, + { + // Version19_2 is CockroachDB v19.2. It's used for all v19.2.x patch releases. + Key: Version19_2, + Version: roachpb.Version{Major: 19, Minor: 2}, + }, // Add new versions here (step two of two). diff --git a/pkg/settings/cluster/cockroach_versions_test.go b/pkg/settings/cluster/cockroach_versions_test.go index 3aa7c6fd0882..2694a7e775a4 100644 --- a/pkg/settings/cluster/cockroach_versions_test.go +++ b/pkg/settings/cluster/cockroach_versions_test.go @@ -18,6 +18,8 @@ import ( ) func TestVersionsAreValid(t *testing.T) { + t.Skip("test skipped on the release 19.2 branch because we haven't " + + "removed old migrations introduced in 19.1") defer leaktest.AfterTest(t)() require.NoError(t, versionsSingleton.Validate()) diff --git a/pkg/settings/cluster/versionkey_string.go b/pkg/settings/cluster/versionkey_string.go index 0b734f192b9e..e93f48e7e57c 100644 --- a/pkg/settings/cluster/versionkey_string.go +++ b/pkg/settings/cluster/versionkey_string.go @@ -23,11 +23,12 @@ func _() { _ = x[VersionAtomicChangeReplicas-12] _ = x[VersionTableDescModificationTimeFromMVCC-13] _ = x[VersionPartitionedBackup-14] + _ = x[Version19_2-15] } -const _VersionKey_name = "Version2_1VersionUnreplicatedRaftTruncatedStateVersionSideloadedStorageNoReplicaIDVersion19_1VersionStart19_2VersionQueryTxnTimestampVersionStickyBitVersionParallelCommitsVersionGenerationComparableVersionLearnerReplicasVersionTopLevelForeignKeysVersionAtomicChangeReplicasTriggerVersionAtomicChangeReplicasVersionTableDescModificationTimeFromMVCCVersionPartitionedBackup" +const _VersionKey_name = "Version2_1VersionUnreplicatedRaftTruncatedStateVersionSideloadedStorageNoReplicaIDVersion19_1VersionStart19_2VersionQueryTxnTimestampVersionStickyBitVersionParallelCommitsVersionGenerationComparableVersionLearnerReplicasVersionTopLevelForeignKeysVersionAtomicChangeReplicasTriggerVersionAtomicChangeReplicasVersionTableDescModificationTimeFromMVCCVersionPartitionedBackupVersion19_2" -var _VersionKey_index = [...]uint16{0, 10, 47, 82, 93, 109, 133, 149, 171, 198, 220, 246, 280, 307, 347, 371} +var _VersionKey_index = [...]uint16{0, 10, 47, 82, 93, 109, 133, 149, 171, 198, 220, 246, 280, 307, 347, 371, 382} func (i VersionKey) String() string { if i < 0 || i >= VersionKey(len(_VersionKey_index)-1) { diff --git a/pkg/sql/logictest/testdata/logic_test/crdb_internal b/pkg/sql/logictest/testdata/logic_test/crdb_internal index 6d570308251a..febc86a92b85 100644 --- a/pkg/sql/logictest/testdata/logic_test/crdb_internal +++ b/pkg/sql/logictest/testdata/logic_test/crdb_internal @@ -289,7 +289,7 @@ select crdb_internal.set_vmodule('') query T select regexp_replace(crdb_internal.node_executable_version()::string, '(-\d+)?$', ''); ---- -19.1 +19.2 query ITTT colnames select node_id, component, field, regexp_replace(regexp_replace(value, '^\d+$', ''), e':\\d+', ':') as value from crdb_internal.node_runtime_info @@ -442,7 +442,7 @@ select * from crdb_internal.gossip_alerts query T select regexp_replace(crdb_internal.node_executable_version()::string, '(-\d+)?$', ''); ---- -19.1 +19.2 user root