summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcos José Grillo Ramirez <marcos.grillo@mongodb.com>2021-02-24 20:34:17 +0100
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-24 22:46:17 +0000
commite9ecd4d9dbe54ff430664fff545f0d76a8b92c70 (patch)
treed5a9803df04d23a61ac84717cae3bb02b9781a6f
parent87ba0743f5d835e1d9f03fbd22de1e4769363e26 (diff)
downloadmongo-e9ecd4d9dbe54ff430664fff545f0d76a8b92c70.tar.gz
SERVER-54635 Add distlocks to resharding command
... to serialize with other DDL operations.
-rw-r--r--jstests/sharding/resharding_disallow_writes.js8
-rw-r--r--jstests/sharding/resharding_prohibited_commands.js2
-rw-r--r--src/mongo/db/s/shardsvr_reshard_collection_command.cpp8
3 files changed, 9 insertions, 9 deletions
diff --git a/jstests/sharding/resharding_disallow_writes.js b/jstests/sharding/resharding_disallow_writes.js
index 2e7362823d1..fe814c237ce 100644
--- a/jstests/sharding/resharding_disallow_writes.js
+++ b/jstests/sharding/resharding_disallow_writes.js
@@ -82,14 +82,6 @@ reshardingTest.withReshardingInBackground(
{dropIndexes: collName, index: {oldKey: 1}, maxTimeMS: 5000}),
ErrorCodes.ReshardCollectionInProgress);
- // TODO(SERVER-54635): This currently succeeds when the
- // featureFlagShardingFullDDLSupport parameter is enabled. Uncomment the code below when
- // this is fixed.
- // jsTestLog("Attempting drop collection");
- // assert.commandFailedWithCode(
- // sourceCollection.runCommand({drop: collName, maxTimeMS: 5000}),
- // ErrorCodes.MaxTimeMSExpired);
-
jsTestLog("Completed operations");
}
});
diff --git a/jstests/sharding/resharding_prohibited_commands.js b/jstests/sharding/resharding_prohibited_commands.js
index c58862cc86d..1b6283a2b7a 100644
--- a/jstests/sharding/resharding_prohibited_commands.js
+++ b/jstests/sharding/resharding_prohibited_commands.js
@@ -51,7 +51,7 @@ reshardingTest.withReshardingInBackground(
assert.commandFailedWithCode(
mongos.adminCommand({moveChunk: ns, find: {oldKey: -10}, to: donorShardNames[1]}),
- ErrorCodes.ConflictingOperationInProgress);
+ ErrorCodes.LockBusy);
assert.commandFailedWithCode(db.runCommand({collMod: 'coll'}),
ErrorCodes.ReshardCollectionInProgress);
assert.commandFailedWithCode(sourceCollection.createIndexes([{newKey: 1}]),
diff --git a/src/mongo/db/s/shardsvr_reshard_collection_command.cpp b/src/mongo/db/s/shardsvr_reshard_collection_command.cpp
index fa6dbad0907..04c8aa85521 100644
--- a/src/mongo/db/s/shardsvr_reshard_collection_command.cpp
+++ b/src/mongo/db/s/shardsvr_reshard_collection_command.cpp
@@ -33,6 +33,7 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/commands.h"
+#include "mongo/db/s/dist_lock_manager.h"
#include "mongo/db/s/reshard_collection_coordinator.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/s/request_types/sharded_ddl_commands_gen.h"
@@ -76,6 +77,13 @@ public:
"Resharding is not supported for this version, please update the FCV to latest.",
!serverGlobalParams.featureCompatibility.isUpgradingOrDowngrading());
+ DistLockManager::ScopedDistLock dbDistLock(
+ uassertStatusOK(DistLockManager::get(opCtx)->lock(
+ opCtx, ns().db(), "reshardCollection", DistLockManager::kDefaultLockTimeout)));
+ DistLockManager::ScopedDistLock collDistLock(
+ uassertStatusOK(DistLockManager::get(opCtx)->lock(
+ opCtx, ns().ns(), "reshardCollection", DistLockManager::kDefaultLockTimeout)));
+
auto reshardCollectionCoordinator =
std::make_shared<ReshardCollectionCoordinator>(opCtx, request());
reshardCollectionCoordinator->run(opCtx).get(opCtx);