diff options
author | Sergi Mateo Bellido <sergi.mateo-bellido@mongodb.com> | 2021-11-29 15:26:19 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-29 17:35:49 +0000 |
commit | 5510a946ad18fc4d91d31ddf06d2d96e7c7ad1de (patch) | |
tree | 87ee5b16f60728d3217e2aabb4acbdce3845e06e | |
parent | 8e983ae3261ea43ea3493fa082683f1aa718e998 (diff) | |
download | mongo-5510a946ad18fc4d91d31ddf06d2d96e7c7ad1de.tar.gz |
SERVER-61689 Fixing ActiveMigrationsRegistry::lock function
(cherry picked from commit 6ef5c857adb8b4d7cee17581c15803558320108d)
with minor modifications
(cherry picked from commit 4809284f259526f8449bab4d8ee774810ecc90e9)
-rw-r--r-- | src/mongo/db/s/active_migrations_registry.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/mongo/db/s/active_migrations_registry.cpp b/src/mongo/db/s/active_migrations_registry.cpp index 70cab089b64..ede2817f8bf 100644 --- a/src/mongo/db/s/active_migrations_registry.cpp +++ b/src/mongo/db/s/active_migrations_registry.cpp @@ -39,6 +39,7 @@ #include "mongo/db/s/migration_source_manager.h" #include "mongo/db/service_context.h" #include "mongo/logv2/log.h" +#include "mongo/util/scopeguard.h" namespace mongo { namespace { @@ -72,10 +73,14 @@ void ActiveMigrationsRegistry::lock(OperationContext* opCtx, StringData reason) LOGV2(467560, "Going to start blocking migrations", "reason"_attr = reason); _migrationsBlocked = true; + auto unblockMigrationsOnError = makeGuard([&] { _migrationsBlocked = false; }); + // Wait for any ongoing chunk modifications to complete opCtx->waitForConditionOrInterrupt(_chunkOperationsStateChangedCV, lock, [this] { return !(_activeMoveChunkState || _activeReceiveChunkState); }); + + unblockMigrationsOnError.dismiss(); } void ActiveMigrationsRegistry::unlock(StringData reason) { |