diff options
author | Matthew Saltz <matthew.saltz@mongodb.com> | 2019-11-22 18:58:48 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-22 18:58:48 +0000 |
commit | 9d6f438e6cb6f51c260727f876423fa2a19ca8c4 (patch) | |
tree | 29e97df07781128c0edcb66db8bd6aab58acc3f4 /src/mongo/db/s | |
parent | dfe9a2f8776a0d5cae7eb2e894fc3fefc7ff2c9a (diff) | |
download | mongo-9d6f438e6cb6f51c260727f876423fa2a19ca8c4.tar.gz |
SERVER-44161 Add migration UUID to StartChunkCloneRequest
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r-- | src/mongo/db/s/SConscript | 17 | ||||
-rw-r--r-- | src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/s/start_chunk_clone_request.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/s/start_chunk_clone_request.h | 16 | ||||
-rw-r--r-- | src/mongo/db/s/start_chunk_clone_request_test.cpp | 3 |
5 files changed, 35 insertions, 15 deletions
diff --git a/src/mongo/db/s/SConscript b/src/mongo/db/s/SConscript index 06f557c108b..bbed7e25b50 100644 --- a/src/mongo/db/s/SConscript +++ b/src/mongo/db/s/SConscript @@ -48,6 +48,7 @@ env.Library( 'migration_chunk_cloner_source_legacy.cpp', 'migration_chunk_cloner_source.cpp', 'migration_destination_manager.cpp', + 'migration_session_id.cpp', 'migration_source_manager.cpp', 'migration_util.cpp', 'move_primary_source_manager.cpp', @@ -70,6 +71,7 @@ env.Library( 'sharding_statistics.cpp', 'split_chunk.cpp', 'split_vector.cpp', + 'start_chunk_clone_request.cpp', env.Idlc('sharding_runtime_d_params.idl')[0], env.Idlc('range_deletion_task.idl')[0], @@ -90,7 +92,6 @@ env.Library( '$BUILD_DIR/mongo/s/client/shard_local', '$BUILD_DIR/mongo/s/sharding_initialization', 'chunk_splitter', - 'migration_types', 'sharding_api_d', 'sharding_catalog_manager', 'sharding_logging', @@ -169,19 +170,6 @@ env.Library( ) env.Library( - target='migration_types', - source=[ - 'migration_session_id.cpp', - 'start_chunk_clone_request.cpp', - ], - LIBDEPS=[ - '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/bson/util/bson_extract', - '$BUILD_DIR/mongo/s/common_s', - ], -) - -env.Library( target='type_shard_identity', source=[ env.Idlc('add_shard_cmd.idl')[0], @@ -349,7 +337,6 @@ env.CppUnitTest( '$BUILD_DIR/mongo/s/config_server_test_fixture', '$BUILD_DIR/mongo/s/sharding_router_test_fixture', 'chunk_splitter', - 'migration_types', 'sharding_logging', 'sharding_runtime_d', 'sharding_runtime_d', diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp index 6162fc725ca..f8920c66800 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp @@ -278,6 +278,9 @@ Status MigrationChunkClonerSourceLegacy::startClone(OperationContext* opCtx) { BSONObjBuilder cmdBuilder; StartChunkCloneRequest::appendAsCommand(&cmdBuilder, _args.getNss(), + // TODO (SERVER-44161): Replace with UUID provided by + // migration donor. + UUID::gen(), _sessionId, _donorConnStr, _args.getFromShardId(), diff --git a/src/mongo/db/s/start_chunk_clone_request.cpp b/src/mongo/db/s/start_chunk_clone_request.cpp index 6fddc248baa..ad350452346 100644 --- a/src/mongo/db/s/start_chunk_clone_request.cpp +++ b/src/mongo/db/s/start_chunk_clone_request.cpp @@ -34,12 +34,15 @@ #include "mongo/base/status_with.h" #include "mongo/bson/bsonobjbuilder.h" #include "mongo/bson/util/bson_extract.h" +#include "mongo/db/commands/feature_compatibility_version.h" namespace mongo { namespace { const char kRecvChunkStart[] = "_recvChunkStart"; const char kFromShardConnectionString[] = "from"; +// Note: The UUID parsing code relies on this field being named 'uuid'. +const char kMigrationId[] = "uuid"; const char kFromShardId[] = "fromShardName"; const char kToShardId[] = "toShardName"; const char kChunkMinKey[] = "min"; @@ -71,6 +74,12 @@ StatusWith<StartChunkCloneRequest> StartChunkCloneRequest::createFromCommand(Nam std::move(sessionIdStatus.getValue()), std::move(secondaryThrottleStatus.getValue())); + // TODO (SERVER-44787): Remove this FCV check after 4.4 is released. + if (serverGlobalParams.featureCompatibility.getVersion() == + ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) { + request._migrationId = UUID::parse(obj); + } + { std::string fromShardConnectionString; Status status = @@ -153,6 +162,7 @@ StatusWith<StartChunkCloneRequest> StartChunkCloneRequest::createFromCommand(Nam void StartChunkCloneRequest::appendAsCommand( BSONObjBuilder* builder, const NamespaceString& nss, + const UUID& migrationId, const MigrationSessionId& sessionId, const ConnectionString& fromShardConnectionString, const ShardId& fromShardId, @@ -166,6 +176,7 @@ void StartChunkCloneRequest::appendAsCommand( invariant(fromShardConnectionString.isValid()); builder->append(kRecvChunkStart, nss.ns()); + migrationId.appendToBuilder(builder, kMigrationId); sessionId.append(builder); builder->append(kFromShardConnectionString, fromShardConnectionString.toString()); builder->append(kFromShardId, fromShardId.toString()); diff --git a/src/mongo/db/s/start_chunk_clone_request.h b/src/mongo/db/s/start_chunk_clone_request.h index 40235a8dc0e..055ba59a459 100644 --- a/src/mongo/db/s/start_chunk_clone_request.h +++ b/src/mongo/db/s/start_chunk_clone_request.h @@ -61,6 +61,7 @@ public: */ static void appendAsCommand(BSONObjBuilder* builder, const NamespaceString& nss, + const UUID& migrationId, const MigrationSessionId& sessionId, const ConnectionString& fromShardConnectionString, const ShardId& fromShardId, @@ -82,6 +83,13 @@ public: return _fromShardCS; } + const UUID& getMigrationId() const { + // getMigrationId() should never be called in a cluster that's not fully upgraded to 4.4. + // TODO (SERVER-44787): Remove this invariant after 4.4 is released. + invariant(_migrationId); + return *_migrationId; + } + const ShardId& getFromShardId() const { return _fromShardId; } @@ -114,6 +122,14 @@ private: // The collection for which this request applies NamespaceString _nss; + /** + * Migration UUID generated by the donor. If the donor is running a 4.2 binary, this will not + * be included in the request, so it's optional. + * + * TODO (SERVER-44787): Make non-optional after 4.4 is released. + */ + boost::optional<UUID> _migrationId; + // The session id of this migration MigrationSessionId _sessionId; diff --git a/src/mongo/db/s/start_chunk_clone_request_test.cpp b/src/mongo/db/s/start_chunk_clone_request_test.cpp index 863d4db905d..0ff6f4ffb35 100644 --- a/src/mongo/db/s/start_chunk_clone_request_test.cpp +++ b/src/mongo/db/s/start_chunk_clone_request_test.cpp @@ -45,11 +45,13 @@ namespace { TEST(StartChunkCloneRequest, CreateAsCommandComplete) { MigrationSessionId sessionId = MigrationSessionId::generate("shard0001", "shard0002"); + UUID migrationId = UUID::gen(); BSONObjBuilder builder; StartChunkCloneRequest::appendAsCommand( &builder, NamespaceString("TestDB.TestColl"), + migrationId, sessionId, assertGet(ConnectionString::parse("TestDonorRS/Donor1:12345,Donor2:12345,Donor3:12345")), ShardId("shard0001"), @@ -66,6 +68,7 @@ TEST(StartChunkCloneRequest, CreateAsCommandComplete) { ASSERT_EQ("TestDB.TestColl", request.getNss().ns()); ASSERT_EQ(sessionId.toString(), request.getSessionId().toString()); + ASSERT(migrationId == request.getMigrationId()); ASSERT(sessionId.matches(request.getSessionId())); ASSERT_EQ( assertGet(ConnectionString::parse("TestDonorRS/Donor1:12345,Donor2:12345,Donor3:12345")) |