diff options
author | Amirsaman Memaripour <amirsaman.memaripour@mongodb.com> | 2021-06-03 13:42:20 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-03 15:29:38 +0000 |
commit | 30dff6a113de31eecf54a0721da61f6d3e781ffa (patch) | |
tree | 3710589ff7fbedc3d32d78decc672f01100761ac | |
parent | a30710cdb1ac6129d1d9d1208b61fe499b02da6f (diff) | |
download | mongo-30dff6a113de31eecf54a0721da61f6d3e781ffa.tar.gz |
SERVER-57378 Fix data-race in the resharding commit monitor unit-tests
-rw-r--r-- | src/mongo/db/s/resharding/resharding_coordinator_commit_monitor.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/s/resharding/resharding_coordinator_commit_monitor_test.cpp | 14 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/mongo/db/s/resharding/resharding_coordinator_commit_monitor.cpp b/src/mongo/db/s/resharding/resharding_coordinator_commit_monitor.cpp index 775fba78a47..91c5868fccc 100644 --- a/src/mongo/db/s/resharding/resharding_coordinator_commit_monitor.cpp +++ b/src/mongo/db/s/resharding/resharding_coordinator_commit_monitor.cpp @@ -54,6 +54,7 @@ namespace resharding { namespace { MONGO_FAIL_POINT_DEFINE(failQueryingRecipients); +MONGO_FAIL_POINT_DEFINE(hangBeforeQueryingRecipients); BSONObj makeCommandObj(const NamespaceString& ns) { auto command = _shardsvrReshardingOperationTime(ns); @@ -139,6 +140,8 @@ Milliseconds CoordinatorCommitMonitor::_queryMaxRemainingOperationTimeForRecipie ReadPreferenceSetting(ReadPreference::PrimaryOnly), Shard::RetryPolicy::kIdempotent); + hangBeforeQueryingRecipients.pauseWhileSet(); + auto maxRemainingTime = Milliseconds(0); while (!ars.done()) { iassert(ErrorCodes::CallbackCanceled, diff --git a/src/mongo/db/s/resharding/resharding_coordinator_commit_monitor_test.cpp b/src/mongo/db/s/resharding/resharding_coordinator_commit_monitor_test.cpp index 2a123e257a4..63d56feb894 100644 --- a/src/mongo/db/s/resharding/resharding_coordinator_commit_monitor_test.cpp +++ b/src/mongo/db/s/resharding/resharding_coordinator_commit_monitor_test.cpp @@ -173,9 +173,17 @@ TEST_F(CoordinatorCommitMonitorTest, UnblocksWhenRecipientsWithinCommitThreshold } TEST_F(CoordinatorCommitMonitorTest, UnblocksWhenCancellationTokenIsCancelled) { - auto future = getCommitMonitor()->waitUntilRecipientsAreWithinCommitThreshold(); - runOnMockingNextResponse([this] { cancelMonitor(); }); - respondWithNotReadyToCommit(); + auto future = [&] { + FailPointEnableBlock fp("hangBeforeQueryingRecipients"); + auto future = getCommitMonitor()->waitUntilRecipientsAreWithinCommitThreshold(); + fp->waitForTimesEntered(fp.initialTimesEntered() + 1); + // Cancels the monitor before waiting for the recipients to respond to the query. Once the + // fail-point is disabled, the monitor should cancel pending network operations and make the + // future ready. Thus, we do not block to run commands on behalf of the mocked network here. + cancelMonitor(); + return future; + }(); + future.get(); } |