diff options
author | Luis Osta <luis.osta@mongodb.com> | 2020-07-15 14:04:48 +0000 |
---|---|---|
committer | Luis Osta <luis.osta@mongodb.com> | 2020-07-17 15:26:06 +0000 |
commit | 1ceca57bcaaa65bdf44064350eb850e9154400dd (patch) | |
tree | c487080112a97b3a79988e358f877ef5df9b1d82 | |
parent | e05dccf26ba6bd0362351cfff841ebdaae1ba23f (diff) | |
download | mongo-1ceca57bcaaa65bdf44064350eb850e9154400dd.tar.gz |
added basic function for mtab blocking
-rw-r--r-- | jstests/replsets/migrating_tenant_mtab_blocks_writes.js | 17 | ||||
-rw-r--r-- | src/mongo/db/repl/migrating_tenant_donor_util.cpp | 29 | ||||
-rw-r--r-- | src/mongo/db/repl/migrating_tenant_donor_util.h | 3 |
3 files changed, 34 insertions, 15 deletions
diff --git a/jstests/replsets/migrating_tenant_mtab_blocks_writes.js b/jstests/replsets/migrating_tenant_mtab_blocks_writes.js new file mode 100644 index 00000000000..a77e7f8328d --- /dev/null +++ b/jstests/replsets/migrating_tenant_mtab_blocks_writes.js @@ -0,0 +1,17 @@ +/** + * + * @tags: [requires_fcv_46] + */ + +(function () { + "use strict"; + + + const rst = new ReplSetTest({ nodes: 1 }); + rst.startSet(); + rst.initiate(); + + assert(true) + + rst.stopSet(); +})();
\ No newline at end of file diff --git a/src/mongo/db/repl/migrating_tenant_donor_util.cpp b/src/mongo/db/repl/migrating_tenant_donor_util.cpp index 6925c391f5f..826551972a6 100644 --- a/src/mongo/db/repl/migrating_tenant_donor_util.cpp +++ b/src/mongo/db/repl/migrating_tenant_donor_util.cpp @@ -83,6 +83,23 @@ void onTransitionToBlocking(OperationContext* opCtx, TenantMigrationDonorDocumen mtab->startBlockingReadsAfter(donorDoc.getBlockTimestamp().get()); } +/** + * Creates a MigratingTenantAccess blocker and then adds it to the MtabByPrefix container through + * the donor document's databasePrefix. + */ +void startTenantMigrationBlockOnPrimary(OperationContext* opCtx, + const TenantMigrationDonorDocument& donorDoc) { + invariant(donorDoc.getState() == TenantMigrationDonorStateEnum::kDataSync); + auto serviceContext = opCtx->getServiceContext(); + + executor::TaskExecutor* mtabExecutor = getTenantMigrationExecutor(serviceContext).get(); + auto mtab = std::make_shared<MigratingTenantAccessBlocker>(serviceContext, mtabExecutor); + + mtab->startBlockingWrites(); + + auto& mtabByPrefix = MigratingTenantAccessBlockerByPrefix::get(serviceContext); + mtabByPrefix.add(donorDoc.getDatabasePrefix(), mtab); +} } // namespace /** @@ -146,19 +163,7 @@ void dataSync(OperationContext* opCtx, const TenantMigrationDonorDocument& origi })); } -void startTenantMigrationBlockOnPrimary(OperationContext* opCtx, - const TenantMigrationDonorDocument& donorDoc) { - invariant(donorDoc.getState() == TenantMigrationDonorStateEnum::kDataSync); - auto serviceContext = opCtx->getServiceContext(); - executor::TaskExecutor* mtabExecutor = getTenantMigrationExecutor(serviceContext).get(); - auto mtab = std::make_shared<MigratingTenantAccessBlocker>(serviceContext, mtabExecutor); - - mtab->startBlockingWrites(); - - auto& mtabByPrefix = MigratingTenantAccessBlockerByPrefix::get(serviceContext); - mtabByPrefix.add(donorDoc.getDatabasePrefix(), mtab); -} std::shared_ptr<executor::TaskExecutor> getTenantMigrationExecutor(ServiceContext* serviceContext) { ThreadPool::Options tpOptions; tpOptions.threadNamePrefix = kThreadNamePrefix; diff --git a/src/mongo/db/repl/migrating_tenant_donor_util.h b/src/mongo/db/repl/migrating_tenant_donor_util.h index da87e083100..64bfe1474ec 100644 --- a/src/mongo/db/repl/migrating_tenant_donor_util.h +++ b/src/mongo/db/repl/migrating_tenant_donor_util.h @@ -53,9 +53,6 @@ std::shared_ptr<executor::TaskExecutor> getTenantMigrationExecutor(ServiceContex * config.migrationDonors document. */ void onTenantMigrationDonorStateTransition(OperationContext* opCtx, const BSONObj& doc); - -void startTenantMigrationBlockOnPrimary(OperationContext* opCtx, const TenantMigrationDonorDocument& donorDoc); - } // namespace migrating_tenant_donor_util } // namespace mongo |