summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJudah Schvimer <judah@mongodb.com>2018-01-22 16:14:30 -0500
committerJudah Schvimer <judah@mongodb.com>2018-01-22 16:14:30 -0500
commitf3b504948c0cef40deffb4786ebdda6797625142 (patch)
tree7a2d0b540d7915dc50b6c5cfc1696ef25e0c57c5 /src
parentc376f4b80d26028b6a8746f8545a35e390b59bf2 (diff)
downloadmongo-f3b504948c0cef40deffb4786ebdda6797625142.tar.gz
SERVER-32794 Make timeouts unrelated to elections not depend on election timeout
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/oplog_fetcher.cpp5
-rw-r--r--src/mongo/db/repl/sync_source_feedback.cpp4
-rw-r--r--src/mongo/db/repl/vote_requester.cpp12
3 files changed, 18 insertions, 3 deletions
diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp
index aff0170db14..e30a2183195 100644
--- a/src/mongo/db/repl/oplog_fetcher.cpp
+++ b/src/mongo/db/repl/oplog_fetcher.cpp
@@ -63,15 +63,18 @@ ServerStatusMetricField<Counter64> displayOpsRead("repl.network.ops", &opsReadSt
Counter64 networkByteStats;
ServerStatusMetricField<Counter64> displayBytesRead("repl.network.bytes", &networkByteStats);
+const Milliseconds maximumAwaitDataTimeoutMS(30 * 1000);
+
/**
* Calculates await data timeout based on the current replica set configuration.
*/
Milliseconds calculateAwaitDataTimeout(const ReplSetConfig& config) {
// Under protocol version 1, make the awaitData timeout (maxTimeMS) dependent on the election
// timeout. This enables the sync source to communicate liveness of the primary to secondaries.
+ // We never wait longer than 30 seconds.
// Under protocol version 0, use a default timeout of 2 seconds for awaitData.
if (config.getProtocolVersion() == 1LL) {
- return config.getElectionTimeoutPeriod() / 2;
+ return std::min((config.getElectionTimeoutPeriod() / 2), maximumAwaitDataTimeoutMS);
}
return OplogFetcher::kDefaultProtocolZeroAwaitDataTimeout;
}
diff --git a/src/mongo/db/repl/sync_source_feedback.cpp b/src/mongo/db/repl/sync_source_feedback.cpp
index 4bd190ff14e..e14abcc8eed 100644
--- a/src/mongo/db/repl/sync_source_feedback.cpp
+++ b/src/mongo/db/repl/sync_source_feedback.cpp
@@ -49,11 +49,13 @@ namespace repl {
namespace {
+const Milliseconds maximumKeepAliveIntervalMS(30 * 1000);
+
/**
* Calculates the keep alive interval based on the given ReplSetConfig.
*/
Milliseconds calculateKeepAliveInterval(const ReplSetConfig& rsConfig) {
- return rsConfig.getElectionTimeoutPeriod() / 2;
+ return std::min((rsConfig.getElectionTimeoutPeriod() / 2), maximumKeepAliveIntervalMS);
}
/**
diff --git a/src/mongo/db/repl/vote_requester.cpp b/src/mongo/db/repl/vote_requester.cpp
index 67d56d004d3..a0c81df3b1d 100644
--- a/src/mongo/db/repl/vote_requester.cpp
+++ b/src/mongo/db/repl/vote_requester.cpp
@@ -42,6 +42,12 @@
namespace mongo {
namespace repl {
+namespace {
+
+const Milliseconds maximumVoteRequestTimeoutMS(30 * 1000);
+
+} // namespace
+
using executor::RemoteCommandRequest;
using executor::RemoteCommandResponse;
@@ -87,7 +93,11 @@ std::vector<RemoteCommandRequest> VoteRequester::Algorithm::getRequests() const
std::vector<RemoteCommandRequest> requests;
for (const auto& target : _targets) {
requests.push_back(RemoteCommandRequest(
- target, "admin", requestVotesCmd, nullptr, _rsConfig.getElectionTimeoutPeriod()));
+ target,
+ "admin",
+ requestVotesCmd,
+ nullptr,
+ std::min(_rsConfig.getElectionTimeoutPeriod(), maximumVoteRequestTimeoutMS)));
}
return requests;