summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2017-04-20 15:28:38 -0400
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2017-04-20 22:36:43 -0400
commit4680351e3fe6f8f47c04440f1c5d1232a4ab7b2d (patch)
treedae7b10842b2e1899a683adf4a545759182ce2ab /src/mongo/db/repl/replication_coordinator_test_fixture.cpp
parent8b437e7a762e3ef99848659dc0d68df1e2add0a4 (diff)
downloadmongo-4680351e3fe6f8f47c04440f1c5d1232a4ab7b2d.tar.gz
SERVER-26848 Exit catchup mode when not syncing more data.
This reverts commit c08590a6ac9dc54c9d910822d47ea17140b56f89.
Diffstat (limited to 'src/mongo/db/repl/replication_coordinator_test_fixture.cpp')
-rw-r--r--src/mongo/db/repl/replication_coordinator_test_fixture.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
index e5a17dd5c1a..aaa00fcdae4 100644
--- a/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
+++ b/src/mongo/db/repl/replication_coordinator_test_fixture.cpp
@@ -323,6 +323,10 @@ void ReplCoordTest::simulateSuccessfulV1ElectionAt(Date_t electionTime) {
ReplSetHeartbeatResponse hbResp;
hbResp.setSetName(rsConfig.getReplSetName());
hbResp.setState(MemberState::RS_SECONDARY);
+ // The smallest valid optime in PV1.
+ OpTime opTime(Timestamp(), 0);
+ hbResp.setAppliedOpTime(opTime);
+ hbResp.setDurableOpTime(opTime);
hbResp.setConfigVersion(rsConfig.getConfigVersion());
net->scheduleResponse(noi, net->now(), makeResponseStatus(hbResp.toBSON(true)));
} else if (request.cmdObj.firstElement().fieldNameStringData() == "replSetRequestVotes") {
@@ -488,32 +492,30 @@ void ReplCoordTest::disableSnapshots() {
_externalState->setAreSnapshotsEnabled(false);
}
-void ReplCoordTest::simulateCatchUpTimeout() {
+void ReplCoordTest::simulateCatchUpAbort() {
NetworkInterfaceMock* net = getNet();
- auto catchUpTimeoutWhen = net->now() + getReplCoord()->getConfig().getCatchUpTimeoutPeriod();
+ auto heartbeatTimeoutWhen =
+ net->now() + getReplCoord()->getConfig().getHeartbeatTimeoutPeriodMillis();
bool hasRequest = false;
net->enterNetwork();
- if (net->now() < catchUpTimeoutWhen) {
- net->runUntil(catchUpTimeoutWhen);
+ if (net->now() < heartbeatTimeoutWhen) {
+ net->runUntil(heartbeatTimeoutWhen);
}
hasRequest = net->hasReadyRequests();
- net->exitNetwork();
-
while (hasRequest) {
- net->enterNetwork();
auto noi = net->getNextReadyRequest();
auto request = noi->getRequest();
// Black hole heartbeat requests caused by time advance.
log() << "Black holing request to " << request.target.toString() << " : " << request.cmdObj;
net->blackHole(noi);
- if (net->now() < catchUpTimeoutWhen) {
- net->runUntil(catchUpTimeoutWhen);
+ if (net->now() < heartbeatTimeoutWhen) {
+ net->runUntil(heartbeatTimeoutWhen);
} else {
net->runReadyNetworkOperations();
}
hasRequest = net->hasReadyRequests();
- net->exitNetwork();
}
+ net->exitNetwork();
}
} // namespace repl