diff options
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/vote_requester.cpp | 20 | ||||
-rw-r--r-- | src/mongo/db/repl/vote_requester.h | 5 | ||||
-rw-r--r-- | src/mongo/db/repl/vote_requester_test.cpp | 6 |
4 files changed, 22 insertions, 11 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp b/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp index 03f2c31afb4..eb41317d933 100644 --- a/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl_elect_v1.cpp @@ -150,6 +150,7 @@ void ReplicationCoordinatorImpl::_startElectSelfV1() { _topCoord->getTerm(), true, // dry run getMyLastOptime(), + _rsConfig.getElectionTimeoutPeriod(), stdx::bind(&ReplicationCoordinatorImpl::_onDryRunComplete, this, term)); if (nextPhaseEvh.getStatus() == ErrorCodes::ShutdownInProgress) { return; @@ -245,6 +246,7 @@ void ReplicationCoordinatorImpl::_startVoteRequester(long long newTerm) { _topCoord->getTerm(), false, getMyLastOptime(), + _rsConfig.getElectionTimeoutPeriod(), stdx::bind(&ReplicationCoordinatorImpl::_onVoteRequestComplete, this, newTerm)); if (nextPhaseEvh.getStatus() == ErrorCodes::ShutdownInProgress) { return; diff --git a/src/mongo/db/repl/vote_requester.cpp b/src/mongo/db/repl/vote_requester.cpp index a8d24c3b496..293965a0954 100644 --- a/src/mongo/db/repl/vote_requester.cpp +++ b/src/mongo/db/repl/vote_requester.cpp @@ -48,12 +48,14 @@ VoteRequester::Algorithm::Algorithm(const ReplicaSetConfig& rsConfig, long long candidateId, long long term, bool dryRun, - OpTime lastOplogEntry) + OpTime lastOplogEntry, + Milliseconds socketTimeout) : _rsConfig(rsConfig), _candidateId(candidateId), _term(term), _dryRun(dryRun), - _lastOplogEntry(lastOplogEntry) { + _lastOplogEntry(lastOplogEntry), + _socketTimeout(socketTimeout) { // populate targets with all voting members that aren't this node for (auto member = _rsConfig.membersBegin(); member != _rsConfig.membersEnd(); member++) { if (member->isVoter() && member->getId() != candidateId) { @@ -82,11 +84,11 @@ std::vector<RemoteCommandRequest> VoteRequester::Algorithm::getRequests() const std::vector<RemoteCommandRequest> requests; for (const auto& target : _targets) { - requests.push_back(RemoteCommandRequest( - target, - "admin", - requestVotesCmd, - Milliseconds(30 * 1000))); // trying to match current Socket timeout + requests.push_back( + RemoteCommandRequest(target, + "admin", + requestVotesCmd, + _socketTimeout)); // trying to match current Socket timeout } return requests; @@ -144,8 +146,10 @@ StatusWith<ReplicationExecutor::EventHandle> VoteRequester::start( long long term, bool dryRun, OpTime lastOplogEntry, + Milliseconds socketTimeout, const stdx::function<void()>& onCompletion) { - _algorithm.reset(new Algorithm(rsConfig, candidateId, term, dryRun, lastOplogEntry)); + _algorithm.reset( + new Algorithm(rsConfig, candidateId, term, dryRun, lastOplogEntry, socketTimeout)); _runner.reset(new ScatterGatherRunner(_algorithm.get())); return _runner->start(executor, onCompletion); } diff --git a/src/mongo/db/repl/vote_requester.h b/src/mongo/db/repl/vote_requester.h index 4c830b8db27..8085e40e1f4 100644 --- a/src/mongo/db/repl/vote_requester.h +++ b/src/mongo/db/repl/vote_requester.h @@ -65,7 +65,8 @@ public: long long candidateId, long long term, bool dryRun, - OpTime lastOplogEntry); + OpTime lastOplogEntry, + Milliseconds socketTimeout); virtual ~Algorithm(); virtual std::vector<executor::RemoteCommandRequest> getRequests() const; virtual void processResponse(const executor::RemoteCommandRequest& request, @@ -95,6 +96,7 @@ public: bool _staleTerm = false; long long _responsesProcessed = 0; long long _votes = 1; + Milliseconds _socketTimeout; }; VoteRequester(); @@ -116,6 +118,7 @@ public: long long term, bool dryRun, OpTime lastOplogEntry, + Milliseconds socketTimeout, const stdx::function<void()>& onCompletion = stdx::function<void()>()); /** diff --git a/src/mongo/db/repl/vote_requester_test.cpp b/src/mongo/db/repl/vote_requester_test.cpp index 70afac4ce8e..7ef738425e8 100644 --- a/src/mongo/db/repl/vote_requester_test.cpp +++ b/src/mongo/db/repl/vote_requester_test.cpp @@ -83,7 +83,8 @@ public: candidateId, term, false, // not a dryRun - lastOplogEntry)); + lastOplogEntry, + Milliseconds(10 * 1000))); } virtual void tearDown() { @@ -215,7 +216,8 @@ public: candidateId, term, true, // dryRun - lastOplogEntry)); + lastOplogEntry, + Milliseconds(10 * 1000))); } }; |