diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2020-12-10 09:14:18 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-10 18:20:53 +0000 |
commit | 4b8f297ca8da46eab9fd668a2c3f4df70724c2ac (patch) | |
tree | e56e62604af22240851cb85625edc35aa5905c40 /src/mongo/db/commands/tenant_migration_recipient_cmds.cpp | |
parent | dfb857953579304273b2737d7c8a094d19d13853 (diff) | |
download | mongo-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.cpp | 21 |
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 {} |