summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLingzhi Deng <lingzhi.deng@mongodb.com>2020-02-14 10:43:20 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-14 19:47:36 +0000
commitfbb3d66a7fdc665c91351730a8fba067fbbbd905 (patch)
treeda9fe3d89bf5e0316ba45bc7413209b1677fbb0d /src
parent94605304208b2d20716ecc09c543e65708751518 (diff)
downloadmongo-fbb3d66a7fdc665c91351730a8fba067fbbbd905.tar.gz
SERVER-46162: Fix race in OplogFetcherAutoReconnectsButFails unit test
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/oplog_fetcher_test.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mongo/db/repl/oplog_fetcher_test.cpp b/src/mongo/db/repl/oplog_fetcher_test.cpp
index 063f32f0762..352d5954916 100644
--- a/src/mongo/db/repl/oplog_fetcher_test.cpp
+++ b/src/mongo/db/repl/oplog_fetcher_test.cpp
@@ -2910,11 +2910,21 @@ TEST_F(NewOplogFetcherTest, OplogFetcherAutoReconnectsButFails) {
auto oplogFetcher = getOplogFetcherAfterConnectionCreated(std::ref(shutdownState), 1);
auto conn = oplogFetcher->getDBClientConnection_forTest();
- // Shut down the mock server and simulate a disconnect for the first find command. And the
- // OplogFetcher should retry with AutoReconnect.
- _mockServer->shutdown();
+
+ auto beforeRecreatingCursor = globalFailPointRegistry().find("hangBeforeOplogFetcherRetries");
+ auto timesEntered = beforeRecreatingCursor->setMode(FailPoint::alwaysOn);
+
+ // Simulate a disconnect for the first find command. And the OplogFetcher should retry with
+ // AutoReconnect.
simulateNetworkDisconnect(conn);
+ // Shut down the mock server before OplogFetcher reconnects.
+ beforeRecreatingCursor->waitForTimesEntered(timesEntered + 1);
+ _mockServer->shutdown();
+
+ // Allow retry and autoreconnect.
+ beforeRecreatingCursor->setMode(FailPoint::off);
+
oplogFetcher->join();
// AutoReconnect should also fail because the server is shut down.