summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2017-02-08 14:12:51 -0500
committerBenety Goh <benety@mongodb.com>2017-02-08 16:26:12 -0500
commitadd23651e74f09a71f48736ad3880d5cad03dfcb (patch)
tree56e4a2ab8ccc9cec5351130f0afafdfcc14cc76f
parent437352cd7dbc158343e2929888d265928b6ca8b7 (diff)
downloadmongo-add23651e74f09a71f48736ad3880d5cad03dfcb.tar.gz
SERVER-27905 fixed race in DataReplicatorTest::DataReplicatorReturnsCallbackCanceledIfShutdownImmediatelyAfterStartup
-rw-r--r--src/mongo/db/repl/data_replicator_test.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/repl/data_replicator_test.cpp b/src/mongo/db/repl/data_replicator_test.cpp
index 5e5388be760..4f841f2f2b7 100644
--- a/src/mongo/db/repl/data_replicator_test.cpp
+++ b/src/mongo/db/repl/data_replicator_test.cpp
@@ -590,6 +590,8 @@ TEST_F(DataReplicatorTest, StartupReturnsShutdownInProgressIfDataReplicatorIsShu
ASSERT_FALSE(dr->isActive());
ASSERT_OK(dr->startup(txn.get(), maxAttempts));
ASSERT_TRUE(dr->isActive());
+ // SyncSourceSelector returns an invalid sync source so DataReplicator is stuck waiting for
+ // another sync source in 'Options::syncSourceRetryWait' ms.
ASSERT_OK(dr->shutdown());
ASSERT_EQUALS(ErrorCodes::ShutdownInProgress, dr->startup(txn.get(), maxAttempts));
}
@@ -638,6 +640,12 @@ TEST_F(DataReplicatorTest, DataReplicatorReturnsCallbackCanceledIfShutdownImmedi
// This will cancel the _startInitialSyncAttemptCallback() task scheduled by startup().
ASSERT_OK(dr->shutdown());
+ // Depending on which DataReplicator stage (_chooseSyncSource or _rollbackCheckerResetCallback)
+ // was interrupted by shutdown(), we may have to request the network interface to deliver
+ // cancellation signals to the DataReplicator callbacks in for DataReplicator to run to
+ // completion.
+ executor::NetworkInterfaceMock::InNetworkGuard(getNet())->runReadyNetworkOperations();
+
dr->join();
ASSERT_EQUALS(ErrorCodes::CallbackCanceled, _lastApplied);