summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdul Qadeer <abdul.qadeer@mongodb.com>2023-04-10 20:56:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-04-10 22:18:26 +0000
commit06c6fc4352fabdc293c17ad4e1c302cfdde21648 (patch)
treeb6dc75efc9262be13e79846ca2b4f392c4da4c7a
parentc74879eb096e195215843ee2086fa616b4884ce9 (diff)
downloadmongo-06c6fc4352fabdc293c17ad4e1c302cfdde21648.tar.gz
SERVER-75871 Return early if cloning state is already initialized
-rw-r--r--src/mongo/db/s/move_primary/move_primary_recipient_service.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mongo/db/s/move_primary/move_primary_recipient_service.cpp b/src/mongo/db/s/move_primary/move_primary_recipient_service.cpp
index 5a10a1bdc4c..08b73e844ba 100644
--- a/src/mongo/db/s/move_primary/move_primary_recipient_service.cpp
+++ b/src/mongo/db/s/move_primary/move_primary_recipient_service.cpp
@@ -556,8 +556,7 @@ MovePrimaryRecipientService::MovePrimaryRecipient::_transitionToDoneStateAndFini
movePrimaryRecipientPauseBeforeDeletingStateDoc.pauseWhileSetAndNotCanceled(
opCtx.get(), _ctHolder->getStepdownToken());
_removeRecipientDocument(opCtx.get());
- })
- .then([this, executor] { return _waitForMajority(executor); });
+ });
})
.onTransientError([](const Status& status) {})
.onUnrecoverableError([](const Status& status) {
@@ -573,12 +572,13 @@ MovePrimaryRecipientService::MovePrimaryRecipient::_transitionToDoneStateAndFini
// Override status code to aborted after logging the original error
status = {ErrorCodes::MovePrimaryAborted, "movePrimary operation aborted"};
}
- if (status.isOK()) {
- stdx::lock_guard<Latch> lg(_mutex);
- move_primary_util::ensureFulfilledPromise(lg, _completionPromise, Status::OK());
- }
- return _waitForMajority(executor).then(
- [this, executor, status] { return ExecutorFuture<void>(**executor, status); });
+ return _waitForMajority(executor).then([this, executor, status] {
+ if (status.isOK()) {
+ stdx::lock_guard<Latch> lg(_mutex);
+ move_primary_util::ensureFulfilledPromise(lg, _completionPromise, Status::OK());
+ }
+ return ExecutorFuture<void>(**executor, status);
+ });
});
}