summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergi Mateo Bellido <sergi.mateo-bellido@mongodb.com>2022-03-31 08:54:16 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-31 09:20:28 +0000
commitbfaa1ac7797c77e2d7f27660363f43f126cf0dce (patch)
tree5342725c8cd9a668d0594b6ed7f8ee2331ee354a
parent16aad2450f4af5887e688ce52b05e6bf873ac13a (diff)
downloadmongo-v5.2.tar.gz
Revert "SERVER-63363 Fixing parsing of ChunkVersion"v5.2
This reverts commit e8942de372206059a8acf80a1a17b2d4b02551a2. (looking for another way to fix this problem)
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/sharding_chunkversion_issue_when_upgrading.js57
-rw-r--r--src/mongo/s/chunk_version.cpp18
-rw-r--r--src/mongo/s/chunk_version_test.cpp2
3 files changed, 7 insertions, 70 deletions
diff --git a/jstests/multiVersion/genericSetFCVUsage/sharding_chunkversion_issue_when_upgrading.js b/jstests/multiVersion/genericSetFCVUsage/sharding_chunkversion_issue_when_upgrading.js
deleted file mode 100644
index 3535063305d..00000000000
--- a/jstests/multiVersion/genericSetFCVUsage/sharding_chunkversion_issue_when_upgrading.js
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * This test verifies that if a router running a 5.0 binary sends a shardVersion without a timestamp
- * to a shard running a 5.1 or greater binary, the router will end up refreshing.
- */
-
-// TODO (SERVER-64813): remove this test once 6.0 becomes lastLTS
-(function() {
-'use strict';
-
-load('jstests/multiVersion/libs/multi_cluster.js'); // For upgradeCluster
-
-var kDbName = 'db';
-var kShardedNss = kDbName + '.foo';
-
-jsTest.log('Deploying cluster version ' + lastLTSFCV);
-var st = new ShardingTest({
- mongos: 1,
- config: 1,
- shards: 2,
- other: {
- mongosOptions: {binVersion: lastLTSFCV},
- configOptions: {binVersion: lastLTSFCV},
- rsOptions: {binVersion: lastLTSFCV},
- rs: {nodes: 2}
- }
-});
-st.configRS.awaitReplication();
-assert.commandWorked(
- st.s.adminCommand({enableSharding: kDbName, primaryShard: st.shard0.shardName}));
-
-jsTest.log('Upgrading FCV to 4.4');
-assert.commandWorked(st.s.adminCommand({setFeatureCompatibilityVersion: "4.4"}));
-
-jsTest.log('Some Workload under FCV 4.4');
-assert.commandWorked(st.s.adminCommand({shardCollection: kShardedNss, key: {i: 1}}));
-assert.commandWorked(st.s.getDB(kDbName).foo.insert({i: 5}));
-
-jsTest.log('Upgrading FCV to ' + lastLTSFCV);
-assert.commandWorked(st.s.adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}));
-
-jsTest.log('Upgrading binaries to ' + latestFCV);
-st.upgradeCluster('latest', {upgradeShards: true, upgradeConfigs: true, upgradeMongos: false});
-
-jsTest.log('Checking that the router has stale information');
-var collVersion = st.s.getDB(kDbName).foo.getShardVersion();
-assert.commandWorked(collVersion);
-assert.eq(collVersion.versionTimestamp, null);
-
-assert.eq(1, st.s.getDB(kDbName).foo.find({i: 5}).itcount());
-
-jsTest.log('Checking that the router refreshed its information');
-collVersion = st.s.getDB(kDbName).foo.getShardVersion();
-assert.commandWorked(collVersion);
-assert.neq(collVersion.versionTimestamp, null);
-
-st.stop();
-})();
diff --git a/src/mongo/s/chunk_version.cpp b/src/mongo/s/chunk_version.cpp
index f249eba8cb6..3379d433f35 100644
--- a/src/mongo/s/chunk_version.cpp
+++ b/src/mongo/s/chunk_version.cpp
@@ -97,11 +97,9 @@ StatusWith<ChunkVersion> ChunkVersion::fromBSON(const BSONObj& obj) {
version._timestamp =
(version.epoch() == UNSHARDED().epoch()) ? Timestamp() : Timestamp::max();
} else {
- // TODO (SERVER-64813): remove this code once 6.0 becomes lastLTS
- // Hack to solve a complex problem related to the addition of the timestamp in 5.0
- uasserted(ErrorCodes::StaleShardVersion,
- str::stream() << "Failed to parse " << obj.toString()
- << " as a ChunkVersion because it is missing the timestamp field.");
+ return {ErrorCodes::TypeMismatch,
+ str::stream() << "Invalid type " << nextElem.type()
+ << " for version timestamp part."};
}
return version;
@@ -153,13 +151,9 @@ StatusWith<ChunkVersion> ChunkVersion::parseLegacyWithField(const BSONObj& obj,
version._timestamp =
(version.epoch() == UNSHARDED().epoch()) ? Timestamp() : Timestamp::max();
} else {
- // TODO (SERVER-64813): remove this code once 6.0 becomes lastLTS
- // Hack to solve a complex problem related to the addition of the timestamp in 5.0
- uasserted(ErrorCodes::StaleShardVersion,
- str::stream()
- << "Failed to parse { epoch: " << version._epoch.toString()
- << ", combined: " << version._combined
- << "} as a ChunkVersion because it is missing the timestamp field.");
+ return {ErrorCodes::TypeMismatch,
+ str::stream() << "Invalid type " << timestampElem.type()
+ << " for version timestamp part."};
}
} else {
invariant(timestampElem.eoo());
diff --git a/src/mongo/s/chunk_version_test.cpp b/src/mongo/s/chunk_version_test.cpp
index 53cf59bea1c..624ff4ae81f 100644
--- a/src/mongo/s/chunk_version_test.cpp
+++ b/src/mongo/s/chunk_version_test.cpp
@@ -71,7 +71,7 @@ TEST(ChunkVersionParsing, FromBSONMissingTimestamp) {
BSON("testVersionField" << BSON_ARRAY(Timestamp(Seconds(2), 3) << OID::gen())),
"testVersionField")),
AssertionException,
- ErrorCodes::StaleShardVersion);
+ ErrorCodes::TypeMismatch);
}
TEST(ChunkVersionParsing, FromBSON) {