diff options
Diffstat (limited to 'src/mongo')
4 files changed, 21 insertions, 32 deletions
diff --git a/src/mongo/s/request_types/set_shard_version_request.cpp b/src/mongo/s/request_types/set_shard_version_request.cpp index 5187ed32c43..208d88b66fa 100644 --- a/src/mongo/s/request_types/set_shard_version_request.cpp +++ b/src/mongo/s/request_types/set_shard_version_request.cpp @@ -45,6 +45,8 @@ namespace { const char kCmdName[] = "setShardVersion"; const char kForceRefresh[] = "forceRefresh"; const char kAuthoritative[] = "authoritative"; +const char kNoConnectionVersioning[] = + "noConnectionVersioning"; // TODO (SERVER-47956): Remove after 4.6 is released } // namespace @@ -102,6 +104,18 @@ StatusWith<SetShardVersionRequest> SetShardVersionRequest::parseFromBSON(const B request._version = versionStatus.getValue(); } + { + bool noConnectionVersioning; + Status status = bsonExtractBooleanFieldWithDefault( + cmdObj, kNoConnectionVersioning, true, &noConnectionVersioning); + if (!status.isOK()) + return status; + if (!noConnectionVersioning) + return {ErrorCodes::Error(47841), + "This is a request with noConnectionVersioning:false, which means it comes " + "from an older version of the server and is not supported."}; + } + return request; } @@ -111,6 +125,7 @@ BSONObj SetShardVersionRequest::toBSON() const { cmdBuilder.append(kCmdName, _nss.get().ns()); cmdBuilder.append(kForceRefresh, _forceRefresh); cmdBuilder.append(kAuthoritative, _isAuthoritative); + cmdBuilder.append(kNoConnectionVersioning, true); _version->appendLegacyWithField(&cmdBuilder, kVersion); diff --git a/src/mongo/s/request_types/set_shard_version_request_test.cpp b/src/mongo/s/request_types/set_shard_version_request_test.cpp index f89feb18e80..ce3d2202cb8 100644 --- a/src/mongo/s/request_types/set_shard_version_request_test.cpp +++ b/src/mongo/s/request_types/set_shard_version_request_test.cpp @@ -112,7 +112,8 @@ TEST(SetShardVersionRequest, ToSSVCommandFull) { ASSERT_BSONOBJ_EQ(ssv.toBSON(), BSON("setShardVersion" << "db.coll" - << "forceRefresh" << false << "authoritative" << false << "version" + << "forceRefresh" << false << "authoritative" << false + << "noConnectionVersioning" << true << "version" << Timestamp(chunkVersion.toLong()) << "versionEpoch" << chunkVersion.epoch())); } @@ -130,7 +131,8 @@ TEST(SetShardVersionRequest, ToSSVCommandFullAuthoritative) { ASSERT_BSONOBJ_EQ(ssv.toBSON(), BSON("setShardVersion" << "db.coll" - << "forceRefresh" << false << "authoritative" << true << "version" + << "forceRefresh" << false << "authoritative" << true + << "noConnectionVersioning" << true << "version" << Timestamp(chunkVersion.toLong()) << "versionEpoch" << chunkVersion.epoch())); } @@ -148,7 +150,8 @@ TEST(SetShardVersionRequest, ToSSVCommandFullForceRefresh) { ASSERT_BSONOBJ_EQ(ssv.toBSON(), BSON("setShardVersion" << "db.coll" - << "forceRefresh" << true << "authoritative" << false << "version" + << "forceRefresh" << true << "authoritative" << false + << "noConnectionVersioning" << true << "version" << Timestamp(chunkVersion.toLong()) << "versionEpoch" << chunkVersion.epoch())); } diff --git a/src/mongo/s/sharding_router_test_fixture.cpp b/src/mongo/s/sharding_router_test_fixture.cpp index f83f7c6186a..92dda1d5c2a 100644 --- a/src/mongo/s/sharding_router_test_fixture.cpp +++ b/src/mongo/s/sharding_router_test_fixture.cpp @@ -68,7 +68,6 @@ #include "mongo/s/config_server_catalog_cache_loader.h" #include "mongo/s/grid.h" #include "mongo/s/query/cluster_cursor_manager.h" -#include "mongo/s/request_types/set_shard_version_request.h" #include "mongo/s/sharding_egress_metadata_hook_for_mongos.h" #include "mongo/s/sharding_task_executor.h" #include "mongo/s/write_ops/batched_command_response.h" @@ -447,26 +446,6 @@ void ShardingTestFixture::expectUpdateCollection(const HostAndPort& expectedHost }); } -void ShardingTestFixture::expectSetShardVersion(const HostAndPort& expectedHost, - const ShardType& expectedShard, - const NamespaceString& expectedNs, - const ChunkVersion& expectedChunkVersion) { - onCommand([&](const RemoteCommandRequest& request) { - ASSERT_EQ(expectedHost, request.target); - ASSERT_BSONOBJ_EQ(rpc::makeEmptyMetadata(), - rpc::TrackingMetadata::removeTrackingData(request.metadata)); - - SetShardVersionRequest ssv = - assertGet(SetShardVersionRequest::parseFromBSON(request.cmdObj)); - - ASSERT(ssv.isAuthoritative()); - ASSERT_EQ(expectedNs, ssv.getNS()); - ASSERT_EQ(expectedChunkVersion.toString(), ssv.getNSVersion().toString()); - - return BSON("ok" << true); - }); -} - void ShardingTestFixture::expectCount(const HostAndPort& configHost, const NamespaceString& expectedNs, const BSONObj& expectedQuery, diff --git a/src/mongo/s/sharding_router_test_fixture.h b/src/mongo/s/sharding_router_test_fixture.h index 84a9b7c5dc3..7f0de2cbd77 100644 --- a/src/mongo/s/sharding_router_test_fixture.h +++ b/src/mongo/s/sharding_router_test_fixture.h @@ -152,14 +152,6 @@ public: const CollectionType& coll, bool expectUpsert = true); - /** - * Expects a setShardVersion command to be executed on the specified shard. - */ - void expectSetShardVersion(const HostAndPort& expectedHost, - const ShardType& expectedShard, - const NamespaceString& expectedNs, - const ChunkVersion& expectedChunkVersion); - void shutdownExecutor(); void setRemote(const HostAndPort& remote); |