Skip to content

Commit

Permalink
[dnm] clusterversion,heartbeat: remove hack to bump versions willy nilly
Browse files Browse the repository at this point in the history
This reverts an earlier commit removing version upgrade safeguards. This
commit will also not be merged.

Release note: None
  • Loading branch information
irfansharif committed Oct 29, 2020
1 parent 678508a commit 4244094
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/clusterversion/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
8 changes: 8 additions & 0 deletions pkg/kv/kvserver/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/rpc/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 4244094

Please sign in to comment.