Skip to content

Instantly share code, notes, and snippets.

@DiannaHohensee
Created November 14, 2016 15:06
Show Gist options
  • Save DiannaHohensee/95c754a53e5f35b1641b936d1ed946d9 to your computer and use it in GitHub Desktop.
Save DiannaHohensee/95c754a53e5f35b1641b936d1ed946d9 to your computer and use it in GitHub Desktop.
diff --git a/src/mongo/db/s/balancer/migration_manager.cpp b/src/mongo/db/s/balancer/migration_manager.cpp
index 4af6282..59c3f76 100644
--- a/src/mongo/db/s/balancer/migration_manager.cpp
+++ b/src/mongo/db/s/balancer/migration_manager.cpp
@@ -296,9 +296,6 @@ void MigrationManager::startRecoveryAndAcquireDistLocks(OperationContext* txn) {
auto distLockManager = Grid::get(txn)->catalogClient(txn)->getDistLockManager();
- // Free any leftover locks from previous instantiations.
- distLockManager->unlockAll(txn, distLockManager->getProcessID());
-
// Claim the balancer lock early to keep any pre-3.4 mongos clients from getting it.
auto balancerLockStatus = distLockManager->tryLockWithLocalWriteConcern(
txn, "balancer", "Config Server Balancer (recovery)", _lockSessionID);
diff --git a/src/mongo/db/s/balancer/migration_manager_test.cpp b/src/mongo/db/s/balancer/migration_manager_test.cpp
index 1025296..8172fad 100644
--- a/src/mongo/db/s/balancer/migration_manager_test.cpp
+++ b/src/mongo/db/s/balancer/migration_manager_test.cpp
@@ -873,6 +873,9 @@ TEST_F(MigrationManagerTest, MigrationRecovery) {
setUpMigration(chunk1, kShardId1.toString());
setUpMigration(chunk2, kShardId3.toString());
+ auto distLockManager = catalogClient()->getDistLockManager();
+ distLockManager->unlockAll(operationContext(), distLockManager->getProcessID());
+
_migrationManager->startRecoveryAndAcquireDistLocks(operationContext());
auto future = launchAsync([this] {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment