From 1dd40ad6ed8aa8a636e7de003185444d04810f75 Mon Sep 17 00:00:00 2001 From: Sergi Mateo Bellido Date: Thu, 31 Mar 2022 12:26:42 +0000 Subject: Revert "SERVER-63363 Fixing parsing of ChunkVersion" This reverts commit e98dc4a89c55c0c391b1a6d1ef6a4be92328cfe9. Looking for a different way of fixing this problem! --- .../sharding_chunkversion_issue_when_upgrading.js | 57 ---------------------- src/mongo/s/chunk_version.cpp | 16 ++---- src/mongo/s/chunk_version_test.cpp | 2 +- 3 files changed, 5 insertions(+), 70 deletions(-) delete mode 100644 jstests/multiVersion/targetedTestsLastLtsFeatures/sharding_chunkversion_issue_when_upgrading.js diff --git a/jstests/multiVersion/targetedTestsLastLtsFeatures/sharding_chunkversion_issue_when_upgrading.js b/jstests/multiVersion/targetedTestsLastLtsFeatures/sharding_chunkversion_issue_when_upgrading.js deleted file mode 100644 index 3535063305d..00000000000 --- a/jstests/multiVersion/targetedTestsLastLtsFeatures/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 2a075c2937b..e162bed1a72 100644 --- a/src/mongo/s/chunk_version.cpp +++ b/src/mongo/s/chunk_version.cpp @@ -92,11 +92,9 @@ ChunkVersion ChunkVersion::_parseArrayOrObjectPositionalFormat(const BSONObj& ob timestamp = (epoch == UNSHARDED().epoch() ? UNSHARDED().getTimestamp() : IGNORED().getTimestamp()); } 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."); + uasserted(ErrorCodes::TypeMismatch, + str::stream() << "Invalid type " << nextElem.type() + << " for version timestamp part."); } ChunkVersion version; @@ -164,13 +162,7 @@ StatusWith ChunkVersion::_parseLegacyWithField(const BSONObj& obj, timestamp = (epoch == UNSHARDED().epoch() ? UNSHARDED().getTimestamp() : IGNORED().getTimestamp()); } 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: " << epoch->toString() - << ", combined: " << combined - << "} as a ChunkVersion because it is missing the timestamp field."); + uasserted(6278300, "Timestamp must be present if epoch exists."); } } else if (!epoch && timestamp) { uasserted(6278301, "Epoch must be present if timestamp exists."); diff --git a/src/mongo/s/chunk_version_test.cpp b/src/mongo/s/chunk_version_test.cpp index e44ce5064ec..d61c99de813 100644 --- a/src/mongo/s/chunk_version_test.cpp +++ b/src/mongo/s/chunk_version_test.cpp @@ -99,7 +99,7 @@ TEST(ChunkVersionParsing, FromBSONMissingTimestamp) { BSON("testVersionField" << BSON_ARRAY( Timestamp(Seconds(2), 3) << OID::gen()))["testVersionField"]), DBException, - ErrorCodes::StaleShardVersion); + ErrorCodes::TypeMismatch); } TEST(ChunkVersionParsing, FromBSON) { -- cgit v1.2.1