summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp
diff options
context:
space:
mode:
authorLingzhi Deng <lingzhi.deng@mongodb.com>2020-12-10 09:14:18 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-12-10 18:20:53 +0000
commit4b8f297ca8da46eab9fd668a2c3f4df70724c2ac (patch)
treee56e62604af22240851cb85625edc35aa5905c40 /src/mongo/db/commands/tenant_migration_recipient_cmds.cpp
parentdfb857953579304273b2737d7c8a094d19d13853 (diff)
downloadmongo-4b8f297ca8da46eab9fd668a2c3f4df70724c2ac.tar.gz
SERVER-48814: Implement recipientForgetMigration command
Diffstat (limited to 'src/mongo/db/commands/tenant_migration_recipient_cmds.cpp')
-rw-r--r--src/mongo/db/commands/tenant_migration_recipient_cmds.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp b/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp
index 26c47c4328b..01728458942 100644
--- a/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp
+++ b/src/mongo/db/commands/tenant_migration_recipient_cmds.cpp
@@ -146,6 +146,27 @@ public:
"recipientForgetMigration command not enabled",
repl::feature_flags::gTenantMigrations.isEnabled(
serverGlobalParams.featureCompatibility));
+ const auto& cmd = request();
+
+ auto recipientService =
+ repl::PrimaryOnlyServiceRegistry::get(opCtx->getServiceContext())
+ ->lookupServiceByName(repl::TenantMigrationRecipientService::
+ kTenantMigrationRecipientServiceName);
+
+ // We may not have a document if recipientForgetMigration is received before
+ // recipientSyncData. But even if that's the case, we still need to create an instance
+ // and persist a state document that's marked garbage collectable (which is done by the
+ // main chain).
+ TenantMigrationRecipientDocument stateDoc(cmd.getMigrationId(),
+ cmd.getDonorConnectionString().toString(),
+ cmd.getTenantId().toString(),
+ cmd.getReadPreference());
+ auto recipientInstance = repl::TenantMigrationRecipientService::Instance::getOrCreate(
+ opCtx, recipientService, stateDoc.toBSON());
+
+ // Instruct the instance run() function to mark this migration garbage collectable.
+ recipientInstance->onReceiveRecipientForgetMigration(opCtx);
+ recipientInstance->getCompletionFuture().get(opCtx);
}
void doCheckAuthorization(OperationContext* opCtx) const {}