summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
diff options
context:
space:
mode:
authorMaria van Keulen <maria@mongodb.com>2019-03-20 20:29:38 -0400
committerMaria van Keulen <maria@mongodb.com>2019-04-16 14:35:34 -0400
commita738647a7281a892f1b35fba8b4e1cdf47bccf56 (patch)
treec76b5fdf490be227bfa7369285fa61a6255e08e5 /src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
parent89ef031427db9efd6ab657de16fd6e0c17cc7797 (diff)
downloadmongo-a738647a7281a892f1b35fba8b4e1cdf47bccf56.tar.gz
SERVER-40078 Report lastCommitted wall clock time
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp200
1 files changed, 117 insertions, 83 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
index c98888fd2f4..56de352ac68 100644
--- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1_test.cpp
@@ -136,8 +136,8 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenNodeIsTheOnlyElectableNode) {
ASSERT(getReplCoord()->getMemberState().secondary())
<< getReplCoord()->getMemberState().toString();
- replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(10, 1), 0));
- replCoordSetMyLastDurableOpTime(OpTime(Timestamp(10, 1), 0));
+ replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(10, 1), 0), Date_t::min() + Seconds(10));
+ replCoordSetMyLastDurableOpTime(OpTime(Timestamp(10, 1), 0), Date_t::min() + Seconds(10));
auto electionTimeoutWhen = getReplCoord()->getElectionTimeout_forTest();
ASSERT_NOT_EQUALS(Date_t(), electionTimeoutWhen);
@@ -200,8 +200,8 @@ TEST_F(ReplCoordTest, StartElectionDoesNotStartAnElectionWhenNodeIsRecovering) {
ASSERT(getReplCoord()->getMemberState().recovering())
<< getReplCoord()->getMemberState().toString();
- replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(10, 1), 0));
- replCoordSetMyLastDurableOpTime(OpTime(Timestamp(10, 1), 0));
+ replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(10, 1), 0), Date_t::min() + Seconds(10));
+ replCoordSetMyLastDurableOpTime(OpTime(Timestamp(10, 1), 0), Date_t::min() + Seconds(10));
simulateEnoughHeartbeatsForAllNodesUp();
auto electionTimeoutWhen = getReplCoord()->getElectionTimeout_forTest();
@@ -221,8 +221,8 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenNodeIsTheOnlyNode) {
<< 1),
HostAndPort("node1", 12345));
- replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(10, 1), 0));
- replCoordSetMyLastDurableOpTime(OpTime(Timestamp(10, 1), 0));
+ replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(10, 1), 0), Date_t::min() + Seconds(10));
+ replCoordSetMyLastDurableOpTime(OpTime(Timestamp(10, 1), 0), Date_t::min() + Seconds(10));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
getReplCoord()->waitForElectionFinish_forTest();
ASSERT(getReplCoord()->getMemberState().primary())
@@ -259,8 +259,8 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenAllNodesVoteYea) {
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
OperationContextNoop opCtx;
- replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0));
- replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0));
+ replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
+ replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
startCapturingLogMessages();
simulateSuccessfulV1Election();
@@ -300,8 +300,8 @@ TEST_F(ReplCoordTest, ElectionSucceedsWhenMaxSevenNodesVoteYea) {
<< 1);
assertStartSuccess(configObj, HostAndPort("node1", 12345));
OperationContextNoop opCtx;
- replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0));
- replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0));
+ replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
+ replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
startCapturingLogMessages();
simulateSuccessfulV1Election();
@@ -337,8 +337,8 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringDryRun)
OperationContextNoop opCtx;
OpTime time1(Timestamp(100, 1), 0);
- replCoordSetMyLastAppliedOpTime(time1);
- replCoordSetMyLastDurableOpTime(time1);
+ replCoordSetMyLastAppliedOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
+ replCoordSetMyLastDurableOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
simulateEnoughHeartbeatsForAllNodesUp();
@@ -398,8 +398,8 @@ TEST_F(ReplCoordTest, ElectionFailsWhenDryRunResponseContainsANewerTerm) {
OperationContextNoop opCtx;
OpTime time1(Timestamp(100, 1), 0);
- replCoordSetMyLastAppliedOpTime(time1);
- replCoordSetMyLastDurableOpTime(time1);
+ replCoordSetMyLastAppliedOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
+ replCoordSetMyLastDurableOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
simulateEnoughHeartbeatsForAllNodesUp();
@@ -466,8 +466,8 @@ TEST_F(ReplCoordTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
<< 1),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0));
- replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0));
+ replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
+ replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
getGlobalFailPointRegistry()
->getFailPoint("blockHeartbeatReconfigFinish")
@@ -495,8 +495,10 @@ TEST_F(ReplCoordTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
hbResp2.setConfigVersion(3);
hbResp2.setSetName("mySet");
hbResp2.setState(MemberState::RS_SECONDARY);
- hbResp2.setAppliedOpTime(OpTime(Timestamp(100, 1), 0));
- hbResp2.setDurableOpTime(OpTime(Timestamp(100, 1), 0));
+ hbResp2.setAppliedOpTimeAndWallTime(
+ {OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100)});
+ hbResp2.setDurableOpTimeAndWallTime(
+ {OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100)});
net->runUntil(net->now() + Seconds(10)); // run until we've sent a heartbeat request
const NetworkInterfaceMock::NetworkOperationIterator noi2 = net->getNextReadyRequest();
net->scheduleResponse(noi2, net->now(), makeResponseStatus(hbResp2.toBSON()));
@@ -528,8 +530,10 @@ TEST_F(ReplCoordTest, NodeWillNotStandForElectionDuringHeartbeatReconfig) {
hbResp.setSetName(rsConfig.getReplSetName());
hbResp.setState(MemberState::RS_SECONDARY);
hbResp.setConfigVersion(rsConfig.getConfigVersion());
- hbResp.setAppliedOpTime(OpTime(Timestamp(100, 1), 0));
- hbResp.setDurableOpTime(OpTime(Timestamp(100, 1), 0));
+ hbResp.setAppliedOpTimeAndWallTime(
+ {OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100)});
+ hbResp.setDurableOpTimeAndWallTime(
+ {OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100)});
BSONObjBuilder respObj;
net->scheduleResponse(noi, net->now(), makeResponseStatus(hbResp.toBSON()));
} else {
@@ -590,8 +594,8 @@ TEST_F(ReplCoordTest, ElectionFailsWhenInsufficientVotesAreReceivedDuringRequest
OperationContextNoop opCtx;
OpTime time1(Timestamp(100, 1), 0);
- replCoordSetMyLastAppliedOpTime(time1);
- replCoordSetMyLastDurableOpTime(time1);
+ replCoordSetMyLastAppliedOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
+ replCoordSetMyLastDurableOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
simulateEnoughHeartbeatsForAllNodesUp();
@@ -640,8 +644,8 @@ TEST_F(ReplCoordTest, TransitionToRollbackFailsWhenElectionInProgress) {
ReplSetConfig config = assertMakeRSConfig(configObj);
OpTime time1(Timestamp(100, 1), 0);
- replCoordSetMyLastAppliedOpTime(time1);
- replCoordSetMyLastDurableOpTime(time1);
+ replCoordSetMyLastAppliedOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
+ replCoordSetMyLastDurableOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
simulateEnoughHeartbeatsForAllNodesUp();
@@ -680,8 +684,8 @@ TEST_F(ReplCoordTest, ElectionFailsWhenVoteRequestResponseContainsANewerTerm) {
OperationContextNoop opCtx;
OpTime time1(Timestamp(100, 1), 0);
- replCoordSetMyLastAppliedOpTime(time1);
- replCoordSetMyLastDurableOpTime(time1);
+ replCoordSetMyLastAppliedOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
+ replCoordSetMyLastDurableOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
simulateEnoughHeartbeatsForAllNodesUp();
@@ -736,8 +740,8 @@ TEST_F(ReplCoordTest, ElectionFailsWhenTermChangesDuringDryRun) {
OperationContextNoop opCtx;
OpTime time1(Timestamp(100, 1), 0);
- replCoordSetMyLastAppliedOpTime(time1);
- replCoordSetMyLastDurableOpTime(time1);
+ replCoordSetMyLastAppliedOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
+ replCoordSetMyLastDurableOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
simulateEnoughHeartbeatsForAllNodesUp();
@@ -776,8 +780,8 @@ TEST_F(ReplCoordTest, ElectionFailsWhenTermChangesDuringActualElection) {
OperationContextNoop opCtx;
OpTime time1(Timestamp(100, 1), 0);
- replCoordSetMyLastAppliedOpTime(time1);
- replCoordSetMyLastDurableOpTime(time1);
+ replCoordSetMyLastAppliedOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
+ replCoordSetMyLastDurableOpTime(time1, Date_t::min() + Seconds(time1.getSecs()));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
simulateEnoughHeartbeatsForAllNodesUp();
@@ -950,8 +954,10 @@ private:
}
hbResp.setConfigVersion(config.getConfigVersion());
hbResp.setTerm(replCoord->getTerm());
- hbResp.setAppliedOpTime(otherNodesOpTime);
- hbResp.setDurableOpTime(otherNodesOpTime);
+ hbResp.setAppliedOpTimeAndWallTime(
+ {otherNodesOpTime, Date_t::min() + Seconds(otherNodesOpTime.getSecs())});
+ hbResp.setDurableOpTimeAndWallTime(
+ {otherNodesOpTime, Date_t::min() + Seconds(otherNodesOpTime.getSecs())});
auto response = makeResponseStatus(hbResp.toBSON());
net->scheduleResponse(noi, net->now(), response);
}
@@ -983,8 +989,10 @@ TEST_F(TakeoverTest, DoesntScheduleCatchupTakeoverIfCatchupDisabledButTakeoverDe
OperationContextNoop opCtx;
OpTime currentOptime(Timestamp(200, 1), 0);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
ASSERT_EQUALS(ErrorCodes::StaleTerm, replCoord->updateTerm(&opCtx, 1));
@@ -1026,8 +1034,10 @@ TEST_F(TakeoverTest, SchedulesCatchupTakeoverIfNodeIsFresherThanCurrentPrimary)
// and some other node became the new primary. Once you hear about a primary election
// in term 1, your term will be increased.
replCoord->updateTerm_forTest(1, nullptr);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
// Make sure we're secondary and that no catchup takeover has been scheduled yet.
@@ -1077,8 +1087,10 @@ TEST_F(TakeoverTest, SchedulesCatchupTakeoverIfBothTakeoversAnOption) {
// and some other node became the new primary. Once you hear about a primary election
// in term 1, your term will be increased.
replCoord->updateTerm_forTest(1, nullptr);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
// Make sure we're secondary and that no catchup takeover has been scheduled.
@@ -1131,8 +1143,10 @@ TEST_F(TakeoverTest, PrefersPriorityToCatchupTakeoverIfNodeHasHighestPriority) {
// and some other node became the new primary. Once you hear about a primary election
// in term 1, your term will be increased.
replCoord->updateTerm_forTest(1, nullptr);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
// Make sure we're secondary and that no catchup takeover has been scheduled.
@@ -1181,8 +1195,10 @@ TEST_F(TakeoverTest, CatchupTakeoverNotScheduledTwice) {
// and some other node became the new primary. Once you hear about a primary election
// in term 1, your term will be increased.
replCoord->updateTerm_forTest(1, nullptr);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
// Make sure we're secondary and that no catchup takeover has been scheduled.
@@ -1246,8 +1262,10 @@ TEST_F(TakeoverTest, CatchupAndPriorityTakeoverNotScheduledAtSameTime) {
// and some other node became the new primary. Once you hear about a primary election
// in term 1, your term will be increased.
replCoord->updateTerm_forTest(1, nullptr);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
// Make sure we're secondary and that no catchup takeover has been scheduled.
@@ -1304,8 +1322,10 @@ TEST_F(TakeoverTest, CatchupTakeoverCallbackCanceledIfElectionTimeoutRuns) {
// and some other node became the new primary. Once you hear about a primary election
// in term 1, your term will be increased.
replCoord->updateTerm_forTest(1, nullptr);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
// Make sure we're secondary and that no catchup takeover has been scheduled.
@@ -1377,8 +1397,10 @@ TEST_F(TakeoverTest, CatchupTakeoverCanceledIfTransitionToRollback) {
// and some other node became the new primary. Once you hear about a primary election
// in term 1, your term will be increased.
replCoord->updateTerm_forTest(1, nullptr);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
// Make sure we're secondary and that no catchup takeover has been scheduled.
@@ -1440,8 +1462,10 @@ TEST_F(TakeoverTest, SuccessfulCatchupTakeover) {
OpTime currentOptime(Timestamp(100, 5000), 0);
OpTime behindOptime(Timestamp(100, 4000), 0);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
// Update the term so that the current term is ahead of the term of
// the last applied op time. This means that the primary is still in
@@ -1511,8 +1535,10 @@ TEST_F(TakeoverTest, CatchupTakeoverDryRunFailsPrimarySaysNo) {
OpTime currentOptime(Timestamp(100, 5000), 0);
OpTime behindOptime(Timestamp(100, 4000), 0);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
// Update the term so that the current term is ahead of the term of
// the last applied op time. This means that the primary is still in
@@ -1613,8 +1639,10 @@ TEST_F(TakeoverTest, PrimaryCatchesUpBeforeCatchupTakeover) {
OperationContextNoop opCtx;
OpTime currentOptime(Timestamp(200, 1), 0);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
// Update the term so that the current term is ahead of the term of
@@ -1678,8 +1706,10 @@ TEST_F(TakeoverTest, PrimaryCatchesUpBeforeHighPriorityNodeCatchupTakeover) {
OperationContextNoop opCtx;
OpTime currentOptime(Timestamp(200, 1), 0);
- replCoordSetMyLastAppliedOpTime(currentOptime);
- replCoordSetMyLastDurableOpTime(currentOptime);
+ replCoordSetMyLastAppliedOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(currentOptime,
+ Date_t::min() + Seconds(currentOptime.getSecs()));
OpTime behindOptime(Timestamp(100, 1), 0);
// Update the term so that the current term is ahead of the term of
@@ -1760,8 +1790,8 @@ TEST_F(TakeoverTest, SchedulesPriorityTakeoverIfNodeHasHigherPriorityThanCurrent
OperationContextNoop opCtx;
OpTime myOptime(Timestamp(100, 1), 0);
- replCoordSetMyLastAppliedOpTime(myOptime);
- replCoordSetMyLastDurableOpTime(myOptime);
+ replCoordSetMyLastAppliedOpTime(myOptime, Date_t::min() + Seconds(myOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(myOptime, Date_t::min() + Seconds(myOptime.getSecs()));
// Make sure we're secondary and that no priority takeover has been scheduled.
ASSERT_OK(replCoord->setFollowerMode(MemberState::RS_SECONDARY));
@@ -1807,8 +1837,8 @@ TEST_F(TakeoverTest, SuccessfulPriorityTakeover) {
OperationContextNoop opCtx;
OpTime myOptime(Timestamp(100, 1), 0);
- replCoordSetMyLastAppliedOpTime(myOptime);
- replCoordSetMyLastDurableOpTime(myOptime);
+ replCoordSetMyLastAppliedOpTime(myOptime, Date_t::min() + Seconds(myOptime.getSecs()));
+ replCoordSetMyLastDurableOpTime(myOptime, Date_t::min() + Seconds(myOptime.getSecs()));
// Make sure we're secondary and that no priority takeover has been scheduled.
ASSERT_OK(replCoord->setFollowerMode(MemberState::RS_SECONDARY));
@@ -1866,8 +1896,8 @@ TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedSameSecond) {
OpTime behindOpTime(Timestamp(100, 3999), 0);
OpTime closeEnoughOpTime(Timestamp(100, 4000), 0);
- replCoordSetMyLastAppliedOpTime(behindOpTime);
- replCoordSetMyLastDurableOpTime(behindOpTime);
+ replCoordSetMyLastAppliedOpTime(behindOpTime, Date_t::min() + Seconds(behindOpTime.getSecs()));
+ replCoordSetMyLastDurableOpTime(behindOpTime, Date_t::min() + Seconds(behindOpTime.getSecs()));
// Make sure we're secondary and that no priority takeover has been scheduled.
ASSERT_OK(replCoord->setFollowerMode(MemberState::RS_SECONDARY));
@@ -1906,8 +1936,10 @@ TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedSameSecond) {
assertValidPriorityTakeoverDelay(config, now, priorityTakeoverTime, 0);
// Now make us caught up enough to call for priority takeover to succeed.
- replCoordSetMyLastAppliedOpTime(closeEnoughOpTime);
- replCoordSetMyLastDurableOpTime(closeEnoughOpTime);
+ replCoordSetMyLastAppliedOpTime(closeEnoughOpTime,
+ Date_t::min() + Seconds(closeEnoughOpTime.getSecs()));
+ replCoordSetMyLastDurableOpTime(closeEnoughOpTime,
+ Date_t::min() + Seconds(closeEnoughOpTime.getSecs()));
LastVote lastVoteExpected = LastVote(replCoord->getTerm() + 1, 0);
performSuccessfulTakeover(priorityTakeoverTime,
@@ -1942,8 +1974,8 @@ TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedDifferentSecond) {
OpTime currentOpTime(Timestamp(100, 1), 0);
OpTime behindOpTime(Timestamp(97, 1), 0);
OpTime closeEnoughOpTime(Timestamp(98, 1), 0);
- replCoordSetMyLastAppliedOpTime(behindOpTime);
- replCoordSetMyLastDurableOpTime(behindOpTime);
+ replCoordSetMyLastAppliedOpTime(behindOpTime, Date_t::min() + Seconds(behindOpTime.getSecs()));
+ replCoordSetMyLastDurableOpTime(behindOpTime, Date_t::min() + Seconds(behindOpTime.getSecs()));
// Make sure we're secondary and that no priority takeover has been scheduled.
ASSERT_OK(replCoord->setFollowerMode(MemberState::RS_SECONDARY));
@@ -1983,8 +2015,10 @@ TEST_F(TakeoverTest, DontCallForPriorityTakeoverWhenLaggedDifferentSecond) {
assertValidPriorityTakeoverDelay(config, now, priorityTakeoverTime, 0);
// Now make us caught up enough to call for priority takeover to succeed.
- replCoordSetMyLastAppliedOpTime(closeEnoughOpTime);
- replCoordSetMyLastDurableOpTime(closeEnoughOpTime);
+ replCoordSetMyLastAppliedOpTime(closeEnoughOpTime,
+ Date_t::min() + Seconds(closeEnoughOpTime.getSecs()));
+ replCoordSetMyLastDurableOpTime(closeEnoughOpTime,
+ Date_t::min() + Seconds(closeEnoughOpTime.getSecs()));
LastVote lastVoteExpected = LastVote(replCoord->getTerm() + 1, 0);
performSuccessfulTakeover(priorityTakeoverTime,
@@ -2011,8 +2045,8 @@ TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringDryRun) {
<< BSON("heartbeatIntervalMillis" << 100)),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0));
- replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0));
+ replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
+ replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
simulateEnoughHeartbeatsForAllNodesUp();
// Advance to dry run vote request phase.
@@ -2076,8 +2110,8 @@ TEST_F(ReplCoordTest, NodeCancelsElectionUponReceivingANewConfigDuringVotePhase)
<< BSON("heartbeatIntervalMillis" << 100)),
HostAndPort("node1", 12345));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
- replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0));
- replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0));
+ replCoordSetMyLastAppliedOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
+ replCoordSetMyLastDurableOpTime(OpTime(Timestamp(100, 1), 0), Date_t::min() + Seconds(100));
simulateEnoughHeartbeatsForAllNodesUp();
simulateSuccessfulDryRun();
ASSERT(TopologyCoordinator::Role::kCandidate == getTopoCoord().getRole());
@@ -2120,8 +2154,8 @@ protected:
hbResp.setSetName(rsConfig.getReplSetName());
hbResp.setState(MemberState::RS_SECONDARY);
hbResp.setConfigVersion(rsConfig.getConfigVersion());
- hbResp.setAppliedOpTime(opTime);
- hbResp.setDurableOpTime(opTime);
+ hbResp.setAppliedOpTimeAndWallTime({opTime, Date_t::min() + Seconds(opTime.getSecs())});
+ hbResp.setDurableOpTimeAndWallTime({opTime, Date_t::min() + Seconds(opTime.getSecs())});
return makeResponseStatus(hbResp.toBSON());
}
@@ -2190,8 +2224,8 @@ protected:
assertStartSuccess(configObj, HostAndPort("node1", 12345));
ReplSetConfig config = assertMakeRSConfig(configObj);
- replCoordSetMyLastAppliedOpTime(opTime);
- replCoordSetMyLastDurableOpTime(opTime);
+ replCoordSetMyLastAppliedOpTime(opTime, Date_t::min() + Seconds(opTime.getSecs()));
+ replCoordSetMyLastDurableOpTime(opTime, Date_t::min() + Seconds(opTime.getSecs()));
ASSERT_OK(getReplCoord()->setFollowerMode(MemberState::RS_SECONDARY));
simulateSuccessfulV1Voting();
@@ -2254,8 +2288,8 @@ protected:
// Simulate the work done by bgsync and applier threads. setMyLastAppliedOpTime() will signal
// the optime waiter.
- void advanceMyLastAppliedOpTime(OpTime opTime) {
- replCoordSetMyLastAppliedOpTime(opTime);
+ void advanceMyLastAppliedOpTime(OpTime opTime, Date_t wallTime = Date_t::min()) {
+ replCoordSetMyLastAppliedOpTime(opTime, wallTime);
getNet()->enterNetwork();
getNet()->runReadyNetworkOperations();
getNet()->exitNetwork();
@@ -2300,7 +2334,7 @@ TEST_F(PrimaryCatchUpTest, CatchupSucceeds) {
net->scheduleResponse(noi, net->now(), makeHeartbeatResponse(time2));
});
ASSERT(getReplCoord()->getApplierState() == ApplierState::Running);
- advanceMyLastAppliedOpTime(time2);
+ advanceMyLastAppliedOpTime(time2, Date_t::min() + Seconds(time2.getSecs()));
ASSERT(getReplCoord()->getApplierState() == ApplierState::Draining);
stopCapturingLogMessages();
ASSERT_EQUALS(1, countLogLinesContaining("Caught up to the latest known optime successfully"));
@@ -2446,7 +2480,7 @@ TEST_F(PrimaryCatchUpTest, PrimaryStepsDownDuringDrainMode) {
});
ReplicationCoordinatorImpl* replCoord = getReplCoord();
ASSERT(getReplCoord()->getApplierState() == ApplierState::Running);
- advanceMyLastAppliedOpTime(time2);
+ advanceMyLastAppliedOpTime(time2, Date_t::min() + Seconds(time2.getSecs()));
ASSERT(replCoord->getApplierState() == ApplierState::Draining);
stopCapturingLogMessages();
ASSERT_EQUALS(1, countLogLinesContaining("Caught up to the latest"));
@@ -2508,7 +2542,7 @@ TEST_F(PrimaryCatchUpTest, FreshestNodeBecomesAvailableLater) {
ASSERT_EQ(1, countLogLinesContaining("Heartbeats updated catchup target optime"));
// 3) Advancing its applied optime to time 2 isn't enough.
- advanceMyLastAppliedOpTime(time2);
+ advanceMyLastAppliedOpTime(time2, Date_t::min() + Seconds(time2.getSecs()));
ASSERT(getReplCoord()->getApplierState() == ApplierState::Running);
// 4) After a while, the other node at time 4 becomes available. Time 4 becomes the new target.
@@ -2528,12 +2562,12 @@ TEST_F(PrimaryCatchUpTest, FreshestNodeBecomesAvailableLater) {
ASSERT_EQ(1, countLogLinesContaining("Heartbeats updated catchup target optime"));
// 5) Advancing to time 3 isn't enough now.
- advanceMyLastAppliedOpTime(time3);
+ advanceMyLastAppliedOpTime(time3, Date_t::min() + Seconds(time3.getSecs()));
ASSERT(getReplCoord()->getApplierState() == ApplierState::Running);
// 6) The node catches up time 4 eventually.
startCapturingLogMessages();
- advanceMyLastAppliedOpTime(time4);
+ advanceMyLastAppliedOpTime(time4, Date_t::min() + Seconds(time4.getSecs()));
ASSERT(getReplCoord()->getApplierState() == ApplierState::Draining);
stopCapturingLogMessages();
ASSERT_EQ(1, countLogLinesContaining("Caught up to the latest"));