summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/shardsvr_move_range_command.cpp
diff options
context:
space:
mode:
authorSviatlana Zuiko <sviatlana.zuiko@mongodb.com>2022-05-06 17:21:51 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-05-06 19:28:52 +0000
commit1113373e84ac5510c4546ec71ec03e6b15d45749 (patch)
treef34f738036177fdd6e8af0e02a9941b2fde3e9d4 /src/mongo/db/s/shardsvr_move_range_command.cpp
parentba5b14fdf75690e5ea663b2c8518542fd28e65c6 (diff)
downloadmongo-1113373e84ac5510c4546ec71ec03e6b15d45749.tar.gz
Revert "SERVER-65371 Ensure that moveRange gets interrupted when the donor steps down"
This reverts commit 417cd065b9f437f01269be04941a183b096f9db5.
Diffstat (limited to 'src/mongo/db/s/shardsvr_move_range_command.cpp')
-rw-r--r--src/mongo/db/s/shardsvr_move_range_command.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/mongo/db/s/shardsvr_move_range_command.cpp b/src/mongo/db/s/shardsvr_move_range_command.cpp
index d1d35335967..a5fc3db4b93 100644
--- a/src/mongo/db/s/shardsvr_move_range_command.cpp
+++ b/src/mongo/db/s/shardsvr_move_range_command.cpp
@@ -31,7 +31,6 @@
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/commands.h"
#include "mongo/db/repl/repl_client_info.h"
-#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/s/active_migrations_registry.h"
#include "mongo/db/s/migration_source_manager.h"
#include "mongo/db/s/sharding_state.h"
@@ -87,6 +86,7 @@ public:
void typedRun(OperationContext* opCtx) {
uassertStatusOK(ShardingState::get(opCtx)->canAcceptShardedCommands());
+ opCtx->setAlwaysInterruptAtStepDownOrUp();
// Make sure we're as up-to-date as possible with shard information. This catches the
// case where we might have changed a shard's host by removing/adding a shard with the
@@ -115,7 +115,7 @@ public:
tc->setSystemOperationKillableByStepdown(lk);
}
auto uniqueOpCtx = Client::getCurrent()->makeOperationContext();
- auto executorOpCtx = uniqueOpCtx.get();
+ auto opCtx = uniqueOpCtx.get();
{
// Ensure that opCtx will get interrupted in the event of a
@@ -123,25 +123,18 @@ public:
// checks that there are no pending migrationCoordinators documents
// (under the ActiveMigrationRegistry lock) on the same term during
// which the migrationCoordinators document will be persisted.
- Lock::GlobalLock lk(executorOpCtx, MODE_IX);
- executorOpCtx->setAlwaysInterruptAtStepDownOrUp();
- uassert(ErrorCodes::InterruptedDueToReplStateChange,
- "Not primary while attempting to start chunk migration "
- "donation",
- repl::ReplicationCoordinator::get(executorOpCtx)
- ->getMemberState()
- .primary());
+ Lock::GlobalLock lk(opCtx, MODE_IX);
}
// Note: This internal authorization is tied to the lifetime of the
// client.
- AuthorizationSession::get(executorOpCtx->getClient())
- ->grantInternalAuthorization(executorOpCtx->getClient());
+ AuthorizationSession::get(opCtx->getClient())
+ ->grantInternalAuthorization(opCtx->getClient());
Status status = {ErrorCodes::InternalError, "Uninitialized value"};
try {
- _runImpl(executorOpCtx, std::move(req), std::move(writeConcern));
+ _runImpl(opCtx, std::move(req), std::move(writeConcern));
status = Status::OK();
} catch (const DBException& e) {
status = e.toStatus();
@@ -151,7 +144,7 @@ public:
"error"_attr = redact(status));
if (status.code() == ErrorCodes::LockTimeout) {
- ShardingStatistics::get(executorOpCtx)
+ ShardingStatistics::get(opCtx)
.countDonorMoveChunkLockTimeout.addAndFetch(1);
}
}