diff options
Diffstat (limited to 'src/mongo/db/s/move_chunk_command.cpp')
-rw-r--r-- | src/mongo/db/s/move_chunk_command.cpp | 52 |
1 files changed, 4 insertions, 48 deletions
diff --git a/src/mongo/db/s/move_chunk_command.cpp b/src/mongo/db/s/move_chunk_command.cpp index 20b649a17df..d00b54b80c4 100644 --- a/src/mongo/db/s/move_chunk_command.cpp +++ b/src/mongo/db/s/move_chunk_command.cpp @@ -42,7 +42,6 @@ #include "mongo/db/s/migration_source_manager.h" #include "mongo/db/s/move_timing_helper.h" #include "mongo/db/s/sharding_state.h" -#include "mongo/s/catalog/dist_lock_manager.h" #include "mongo/s/client/shard_registry.h" #include "mongo/s/grid.h" #include "mongo/s/migration_secondary_throttle_options.h" @@ -58,30 +57,6 @@ using std::string; namespace { /** - * Acquires a distributed lock for the specified collection or throws if lock cannot be acquired. - */ -DistLockManager::ScopedDistLock acquireCollectionDistLock(OperationContext* txn, - const MoveChunkRequest& args) { - const string whyMessage(str::stream() - << "migrating chunk " - << ChunkRange(args.getMinKey(), args.getMaxKey()).toString() - << " in " - << args.getNss().ns()); - auto distLockStatus = Grid::get(txn)->catalogClient(txn)->getDistLockManager()->lock( - txn, args.getNss().ns(), whyMessage, DistLockManager::kSingleLockAttemptTimeout); - if (!distLockStatus.isOK()) { - const string msg = str::stream() - << "Could not acquire collection lock for " << args.getNss().ns() - << " to migrate chunk [" << redact(args.getMinKey()) << "," << redact(args.getMaxKey()) - << ") due to " << distLockStatus.getStatus().toString(); - warning() << msg; - uasserted(distLockStatus.getStatus().code(), msg); - } - - return std::move(distLockStatus.getValue()); -} - -/** * If the specified status is not OK logs a warning and throws a DBException corresponding to the * specified status. */ @@ -184,11 +159,11 @@ public: if (status == ErrorCodes::ChunkTooBig) { // This code is for compatibility with pre-3.2 balancer, which does not recognize the - // ChunkTooBig error code and instead uses the "chunkTooBig" field in the response. - // TODO: Remove after 3.4 is released. - errmsg = status.reason(); + // ChunkTooBig error code and instead uses the "chunkTooBig" field in the response, + // and the 3.4 shard, which failed to set the ChunkTooBig status code. + // TODO: Remove after 3.6 is released. result.appendBool("chunkTooBig", true); - return false; + return appendCommandStatus(result, status); } uassertStatusOK(status); @@ -232,12 +207,6 @@ private: BSONObj shardKeyPattern; { - // Acquire the collection distributed lock if necessary - boost::optional<DistLockManager::ScopedDistLock> scopedCollectionDistLock; - if (moveChunkRequest.getTakeDistLock()) { - scopedCollectionDistLock = acquireCollectionDistLock(txn, moveChunkRequest); - } - MigrationSourceManager migrationSourceManager( txn, moveChunkRequest, donorConnStr, recipientHost); @@ -254,19 +223,6 @@ private: moveTimingHelper.done(4); MONGO_FAIL_POINT_PAUSE_WHILE_SET(moveChunkHangAtStep4); - // Ensure the distributed lock is still held if this shard owns it. - if (moveChunkRequest.getTakeDistLock()) { - Status checkDistLockStatus = scopedCollectionDistLock->checkStatus(); - if (!checkDistLockStatus.isOK()) { - migrationSourceManager.cleanupOnError(txn); - - uassertStatusOKWithWarning( - {checkDistLockStatus.code(), - str::stream() << "not entering migrate critical section due to " - << checkDistLockStatus.toString()}); - } - } - uassertStatusOKWithWarning(migrationSourceManager.enterCriticalSection(txn)); uassertStatusOKWithWarning(migrationSourceManager.commitChunkOnRecipient(txn)); moveTimingHelper.done(5); |