From 4b8f297ca8da46eab9fd668a2c3f4df70724c2ac Mon Sep 17 00:00:00 2001 From: Lingzhi Deng Date: Thu, 10 Dec 2020 09:14:18 -0500 Subject: SERVER-48814: Implement recipientForgetMigration command --- .../db/commands/tenant_migration_recipient_cmds.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/mongo/db/commands/tenant_migration_recipient_cmds.cpp') 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 {} -- cgit v1.2.1