diff options
author | Matt Broadstone <mbroadst@mongodb.com> | 2022-09-14 23:05:50 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-15 00:19:47 +0000 |
commit | 1a13031f7cdfb6cffdcff212edef0790fe084df2 (patch) | |
tree | 8d6ba207b94133d0775d398c3384380dfcc8343a /src/mongo/db/repl/tenant_migration_donor_op_observer.cpp | |
parent | d1da149077ea312efc80f8836bc79f2b1b10c1ad (diff) | |
download | mongo-1a13031f7cdfb6cffdcff212edef0790fe084df2.tar.gz |
SERVER-65315 Enforce mutual exclusion between serverless operations
Diffstat (limited to 'src/mongo/db/repl/tenant_migration_donor_op_observer.cpp')
-rw-r--r-- | src/mongo/db/repl/tenant_migration_donor_op_observer.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/repl/tenant_migration_donor_op_observer.cpp b/src/mongo/db/repl/tenant_migration_donor_op_observer.cpp index 264099e24cf..29ec527b2a9 100644 --- a/src/mongo/db/repl/tenant_migration_donor_op_observer.cpp +++ b/src/mongo/db/repl/tenant_migration_donor_op_observer.cpp @@ -34,6 +34,7 @@ #include "mongo/db/repl/tenant_migration_decoration.h" #include "mongo/db/repl/tenant_migration_donor_op_observer.h" #include "mongo/db/repl/tenant_migration_state_machine_gen.h" +#include "mongo/db/serverless/serverless_operation_lock_registry.h" #include "mongo/logv2/log.h" #define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kReplication @@ -54,6 +55,10 @@ void onTransitionToAbortingIndexBuilds(OperationContext* opCtx, const TenantMigrationDonorDocument& donorStateDoc) { invariant(donorStateDoc.getState() == TenantMigrationDonorStateEnum::kAbortingIndexBuilds); + ServerlessOperationLockRegistry::get(opCtx->getServiceContext()) + .acquireLock(ServerlessOperationLockRegistry::LockType::kTenantDonor, + donorStateDoc.getId()); + auto mtab = std::make_shared<TenantMigrationDonorAccessBlocker>(opCtx->getServiceContext(), donorStateDoc.getId()); if (donorStateDoc.getProtocol().value_or(MigrationProtocolEnum::kMultitenantMigrations) == @@ -69,6 +74,9 @@ void onTransitionToAbortingIndexBuilds(OperationContext* opCtx, TenantMigrationAccessBlockerRegistry::get(opCtx->getServiceContext()) .remove(donorStateDoc.getTenantId(), TenantMigrationAccessBlocker::BlockerType::kDonor); + ServerlessOperationLockRegistry::get(opCtx->getServiceContext()) + .releaseLock(ServerlessOperationLockRegistry::LockType::kTenantDonor, + donorStateDoc.getId()); }); } } else { @@ -85,6 +93,9 @@ void onTransitionToAbortingIndexBuilds(OperationContext* opCtx, opCtx->recoveryUnit()->onRollback([opCtx, donorStateDoc] { TenantMigrationAccessBlockerRegistry::get(opCtx->getServiceContext()) .removeShardMergeDonorAccessBlocker(donorStateDoc.getId()); + ServerlessOperationLockRegistry::get(opCtx->getServiceContext()) + .releaseLock(ServerlessOperationLockRegistry::LockType::kTenantDonor, + donorStateDoc.getId()); }); } } @@ -156,6 +167,10 @@ public: void commit(boost::optional<Timestamp>) override { if (_donorStateDoc.getExpireAt()) { + ServerlessOperationLockRegistry::get(_opCtx->getServiceContext()) + .releaseLock(ServerlessOperationLockRegistry::LockType::kTenantDonor, + _donorStateDoc.getId()); + auto mtab = tenant_migration_access_blocker::getTenantMigrationDonorAccessBlocker( _opCtx->getServiceContext(), _donorStateDoc.getTenantId()); @@ -339,6 +354,9 @@ repl::OpTime TenantMigrationDonorOpObserver::onDropCollection(OperationContext* opCtx->recoveryUnit()->onCommit([opCtx](boost::optional<Timestamp>) { TenantMigrationAccessBlockerRegistry::get(opCtx->getServiceContext()) .removeAll(TenantMigrationAccessBlocker::BlockerType::kDonor); + + ServerlessOperationLockRegistry::get(opCtx->getServiceContext()) + .onDropStateCollection(ServerlessOperationLockRegistry::LockType::kTenantDonor); }); } return {}; |