summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornandinibhartiyaMDB <nandini.bhartiya@mongodb.com>2022-06-08 15:53:17 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-09 15:02:22 +0000
commit52f58747e86fedf2ca095f16a64b41cc6c565034 (patch)
tree7ccac61cd30bbe234727dbbd1051ff8f8566ceed /src
parent9847e9146a43f4b5b2c24cd0b22690ac612b64cc (diff)
downloadmongo-52f58747e86fedf2ca095f16a64b41cc6c565034.tar.gz
SERVER-66046: Abort resharding on recipient errors
(cherry picked from commit f016b1053908e031dbcec48ffb0a30fa63ba7e3d)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/s/resharding/resharding_coordinator_service.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mongo/db/s/resharding/resharding_coordinator_service.cpp b/src/mongo/db/s/resharding/resharding_coordinator_service.cpp
index 99f98abf0a7..85c14b6478f 100644
--- a/src/mongo/db/s/resharding/resharding_coordinator_service.cpp
+++ b/src/mongo/db/s/resharding/resharding_coordinator_service.cpp
@@ -1665,9 +1665,22 @@ ReshardingCoordinatorService::ReshardingCoordinator::_awaitAllRecipientsFinished
_startCommitMonitor(executor);
LOGV2(5391602, "Resharding operation waiting for an okay to enter critical section");
- return future_util::withCancellation(_canEnterCritical.getFuture(),
- _ctHolder->getAbortToken())
+
+ // The _reshardingCoordinatorObserver->awaitAllRecipientsInStrictConsistency() future is
+ // used for reporting recipient shard errors encountered during the Applying phase and
+ // in turn aborting the resharding operation.
+ // For all other cases, the _canEnterCritical.getFuture() resolves first and the
+ // operation can then proceed to entering the critical section depending on the status
+ // returned.
+ return future_util::withCancellation(
+ whenAny(
+ _canEnterCritical.getFuture().thenRunOn(**executor),
+ _reshardingCoordinatorObserver->awaitAllRecipientsInStrictConsistency()
+ .thenRunOn(**executor)
+ .ignoreValue()),
+ _ctHolder->getAbortToken())
.thenRunOn(**executor)
+ .then([](auto result) { return result.result; })
.onCompletion([this](Status status) {
_ctHolder->cancelCommitMonitor();
if (status.isOK()) {