diff options
author | Ali Mir <ali.mir@mongodb.com> | 2020-06-21 18:27:30 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-20 13:08:14 +0000 |
commit | c81faca5abb75f351f2760cd3a5c971019e3c3f4 (patch) | |
tree | f9fb90167025134a33ccbd20951b4c7fde770d88 | |
parent | 85f08829bae59d88a5b88e7aa9babcf16758b450 (diff) | |
download | mongo-c81faca5abb75f351f2760cd3a5c971019e3c3f4.tar.gz |
SERVER-48982 Respond to heartbeats until reconfig thread finishes in StepdownShouldInterruptConfigWrite
(cherry picked from commit 5a19643afe9881a3a8178a027779b704984b8067)
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp index 45037075cd4..ce9b9924ffa 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_reconfig_test.cpp @@ -42,6 +42,7 @@ #include "mongo/db/repl/replication_coordinator_test_fixture.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/logv2/log.h" +#include "mongo/stdx/future.h" #include "mongo/unittest/log_test.h" #include "mongo/unittest/unittest.h" #include "mongo/util/fail_point.h" @@ -1389,9 +1390,9 @@ TEST_F(ReplCoordReconfigTest, StepdownShouldInterruptConfigWrite) { BSONObjBuilder result; Status status(ErrorCodes::InternalError, "Not Set"); const auto opCtx = makeOperationContext(); - stdx::thread reconfigThread; - reconfigThread = stdx::thread( - [&] { status = getReplCoord()->processReplSetReconfig(opCtx.get(), args, &result); }); + auto reconfigResult = stdx::async(stdx::launch::async, [&] { + status = getReplCoord()->processReplSetReconfig(opCtx.get(), args, &result); + }); getNet()->enterNetwork(); // Wait for the next heartbeat of quorum check and blackhole it. @@ -1407,10 +1408,13 @@ TEST_F(ReplCoordReconfigTest, StepdownShouldInterruptConfigWrite) { ASSERT(updateTermEvh.isValid()); getReplExec()->waitForEvent(updateTermEvh); - // Respond to quorum check to resume the reconfig. - respondToAllHeartbeats(); + // Respond to quorum check to resume the reconfig. We keep responding until the reconfig thread + // finishes. + while (stdx::future_status::ready != + reconfigResult.wait_for(Milliseconds::zero().toSystemDuration())) { + respondToAllHeartbeats(); + } - reconfigThread.join(); ASSERT_EQ(status.code(), ErrorCodes::NotMaster); ASSERT_EQ(status.reason(), "Stepped down when persisting new config"); } |