diff options
author | Suganthi Mani <suganthi.mani@mongodb.com> | 2021-11-02 20:07:09 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-02 20:53:19 +0000 |
commit | bbc96fbba2deaac539165bcd86bbdaf6037f41dd (patch) | |
tree | d45d57646ae12e4d347fc25b00e72c7b54eb7c71 /src/mongo/db/commands/tenant_migration_recipient_cmds.cpp | |
parent | d47a25210252140172b9f8aa99f78662d7c1fcaf (diff) | |
download | mongo-bbc96fbba2deaac539165bcd86bbdaf6037f41dd.tar.gz |
SERVER-59495 Donor and recipient tenant migration state machines will persist the migration protocol info and tenantId info will be an empty string for 'Merge' protocol.
Diffstat (limited to 'src/mongo/db/commands/tenant_migration_recipient_cmds.cpp')
-rw-r--r-- | src/mongo/db/commands/tenant_migration_recipient_cmds.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp b/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp index b854b45924e..6120097c424 100644 --- a/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp +++ b/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp @@ -34,7 +34,6 @@ #include "mongo/db/commands/tenant_migration_donor_cmds_gen.h" #include "mongo/db/commands/tenant_migration_recipient_cmds_gen.h" #include "mongo/db/repl/primary_only_service.h" -#include "mongo/db/repl/repl_server_parameters_gen.h" #include "mongo/db/repl/tenant_migration_recipient_service.h" #include "mongo/logv2/log.h" @@ -42,6 +41,7 @@ namespace mongo { namespace { MONGO_FAIL_POINT_DEFINE(returnResponseOkForRecipientSyncDataCmd); +MONGO_FAIL_POINT_DEFINE(returnResponseOkForRecipientForgetMigrationCmd); class RecipientSyncDataCmd : public TypedCommand<RecipientSyncDataCmd> { public: @@ -70,6 +70,10 @@ public: !serverGlobalParams.featureCompatibility.isUpgradingOrDowngrading()); const auto& cmd = request(); + const auto migrationProtocol = cmd.getProtocol().value_or(kDefaulMigrationProtocol); + + tenant_migration_util::protocolTenantIdCompatibilityCheck(migrationProtocol, + cmd.getTenantId().toString()); TenantMigrationRecipientDocument stateDoc(cmd.getMigrationId(), cmd.getDonorConnectionString().toString(), @@ -77,6 +81,7 @@ public: cmd.getStartMigrationDonorTimestamp(), cmd.getReadPreference()); + if (!repl::tenantMigrationDisableX509Auth) { uassert(ErrorCodes::InvalidOptions, str::stream() << "'" << Request::kRecipientCertificateForDonorFieldName @@ -85,11 +90,14 @@ public: stateDoc.setRecipientCertificateForDonor(cmd.getRecipientCertificateForDonor()); } + stateDoc.setProtocol(migrationProtocol); + const auto stateDocBson = stateDoc.toBSON(); if (MONGO_unlikely(returnResponseOkForRecipientSyncDataCmd.shouldFail())) { LOGV2(4879608, - "'returnResponseOkForRecipientSyncDataCmd' failpoint enabled.", + "Immediately returning OK because 'returnResponseOkForRecipientSyncDataCmd' " + "failpoint is enabled.", "tenantMigrationRecipientInstance"_attr = stateDoc.toBSON()); return Response(repl::OpTime()); } @@ -181,6 +189,10 @@ public: serverGlobalParams.clusterRole == ClusterRole::ShardServer); const auto& cmd = request(); + const auto migrationProtocol = cmd.getProtocol().value_or(kDefaulMigrationProtocol); + + tenant_migration_util::protocolTenantIdCompatibilityCheck(migrationProtocol, + cmd.getTenantId().toString()); opCtx->setAlwaysInterruptAtStepDownOrUp(); auto recipientService = @@ -205,12 +217,21 @@ public: cmd.getRecipientCertificateForDonor()); stateDoc.setRecipientCertificateForDonor(cmd.getRecipientCertificateForDonor()); } - + stateDoc.setProtocol(migrationProtocol); // Set the state to 'kDone' so that we don't create a recipient access blocker // unnecessarily if this recipientForgetMigration command is received before a // recipientSyncData command or after the state doc is garbage collected. stateDoc.setState(TenantMigrationRecipientStateEnum::kDone); + + if (MONGO_unlikely(returnResponseOkForRecipientForgetMigrationCmd.shouldFail())) { + LOGV2(5949502, + "Immediately returning ok because " + "'returnResponseOkForRecipientForgetMigrationCmd' failpoint is enabled", + "tenantMigrationRecipientInstance"_attr = stateDoc.toBSON()); + return; + } + auto recipientInstance = repl::TenantMigrationRecipientService::Instance::getOrCreate( opCtx, recipientService, stateDoc.toBSON()); |