diff options
author | Abdul Qadeer <abdul.qadeer@mongodb.com> | 2023-04-10 20:56:00 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-04-10 22:18:26 +0000 |
commit | 06c6fc4352fabdc293c17ad4e1c302cfdde21648 (patch) | |
tree | b6dc75efc9262be13e79846ca2b4f392c4da4c7a | |
parent | c74879eb096e195215843ee2086fa616b4884ce9 (diff) | |
download | mongo-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.cpp | 16 |
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); + }); }); } |