From 4244094cef645a8b739cb1b40285da1ecf027bc5 Mon Sep 17 00:00:00 2001 From: irfan sharif Date: Thu, 29 Oct 2020 02:14:43 -0400 Subject: [PATCH] [dnm] clusterversion,heartbeat: remove hack to bump versions willy nilly This reverts an earlier commit removing version upgrade safeguards. This commit will also not be merged. Release note: None --- pkg/clusterversion/setting.go | 5 +++++ pkg/kv/kvserver/stores.go | 8 ++++++++ pkg/rpc/heartbeat.go | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/pkg/clusterversion/setting.go b/pkg/clusterversion/setting.go index 5a8ff50b650..410c87797de 100644 --- a/pkg/clusterversion/setting.go +++ b/pkg/clusterversion/setting.go @@ -225,6 +225,11 @@ func (cv *clusterVersionSetting) validateBinaryVersions( if vh.BinaryMinSupportedVersion() == (roachpb.Version{}) { panic("BinaryMinSupportedVersion not set") } + if vh.BinaryVersion().Less(ver) { + // TODO(tschottdorf): also ask gossip about other nodes. + return errors.Errorf("cannot upgrade to %s: node running %s", + ver, vh.BinaryVersion()) + } if ver.Less(vh.BinaryMinSupportedVersion()) { return errors.Errorf("node at %s cannot run %s (minimum version is %s)", vh.BinaryVersion(), ver, vh.BinaryMinSupportedVersion()) diff --git a/pkg/kv/kvserver/stores.go b/pkg/kv/kvserver/stores.go index 593e771d436..3249bf6c6bc 100644 --- a/pkg/kv/kvserver/stores.go +++ b/pkg/kv/kvserver/stores.go @@ -340,6 +340,14 @@ func SynthesizeClusterVersionFromEngines( cv.Version = binaryMinSupportedVersion } + // Avoid running a binary with a store that is too new. For example, + // restarting into 1.1 after having upgraded to 1.2 doesn't work. + if binaryVersion.Less(cv.Version) { + return clusterversion.ClusterVersion{}, errors.Errorf( + "cockroach version v%s is incompatible with data in store %s; use version v%s or later", + binaryVersion, eng, cv.Version) + } + // Track smallest use version encountered. if cv.Version.Less(minStoreVersion.Version) { minStoreVersion.Version = cv.Version diff --git a/pkg/rpc/heartbeat.go b/pkg/rpc/heartbeat.go index f951c8f8506..f0540bc31fb 100644 --- a/pkg/rpc/heartbeat.go +++ b/pkg/rpc/heartbeat.go @@ -90,6 +90,10 @@ func checkVersion(ctx context.Context, st *cluster.Settings, peerVersion roachpb return errors.Errorf( "cluster requires at least version %s, but peer did not provide a version", activeVersion) } + if peerVersion.Less(activeVersion.Version) { + return errors.Errorf( + "cluster requires at least version %s, but peer has version %s", activeVersion, peerVersion) + } return nil }