diff options
author | Spencer T Brody <spencer@mongodb.com> | 2017-02-14 11:56:21 -0500 |
---|---|---|
committer | Spencer T Brody <spencer@mongodb.com> | 2017-03-02 11:00:50 -0500 |
commit | 633a7101f5c0c21ef895b92c695dee9f012bbefc (patch) | |
tree | ea60b3a2e77fb7fe8aca831f612ebe3902cc057e | |
parent | 086c21e2b4c87952273fde78ab8fb18f18e8fdc6 (diff) | |
download | mongo-633a7101f5c0c21ef895b92c695dee9f012bbefc.tar.gz |
SERVER-28005 Increase network timeout on oplog queries to be larger than the maxTimeMs
(cherry picked from commit f6006942e76377c9434a61e76a7803eb83430591)
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher.cpp | 40 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher.h | 1 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher_test.cpp | 15 |
3 files changed, 19 insertions, 37 deletions
diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp index f976b9ac18d..e578968cc9e 100644 --- a/src/mongo/db/repl/oplog_fetcher.cpp +++ b/src/mongo/db/repl/oplog_fetcher.cpp @@ -55,6 +55,23 @@ MONGO_FP_DECLARE(stopReplProducer); namespace { +Seconds kOplogInitialFindMaxTime{60}; +Seconds kOplogQueryNetworkTimeout{65}; // 5 seconds past the find command's 1 minute maxTimeMs + +Counter64 readersCreatedStats; +ServerStatusMetricField<Counter64> displayReadersCreated("repl.network.readersCreated", + &readersCreatedStats); +// The number and time spent reading batches off the network +TimerStats getmoreReplStats; +ServerStatusMetricField<TimerStats> displayBatchesRecieved("repl.network.getmores", + &getmoreReplStats); +// The oplog entries read via the oplog reader +Counter64 opsReadStats; +ServerStatusMetricField<Counter64> displayOpsRead("repl.network.ops", &opsReadStats); +// The bytes read via the oplog reader +Counter64 networkByteStats; +ServerStatusMetricField<Counter64> displayBytesRead("repl.network.bytes", &networkByteStats); + /** * Calculates await data timeout based on the current replica set configuration. */ @@ -81,7 +98,7 @@ BSONObj makeFindCommandObject(DataReplicatorExternalState* dataReplicatorExterna cmdBob.append("tailable", true); cmdBob.append("oplogReplay", true); cmdBob.append("awaitData", true); - cmdBob.append("maxTimeMS", durationCount<Milliseconds>(Minutes(1))); // 1 min initial find. + cmdBob.append("maxTimeMS", durationCount<Milliseconds>(kOplogInitialFindMaxTime)); auto opTimeWithTerm = dataReplicatorExternalState->getCurrentTermAndLastCommittedOpTime(); if (opTimeWithTerm.value != OpTime::kUninitializedTerm) { cmdBob.append("term", opTimeWithTerm.value); @@ -164,20 +181,6 @@ Status checkRemoteOplogStart(const Fetcher::Documents& documents, OpTimeWithHash return Status::OK(); } -Counter64 readersCreatedStats; -ServerStatusMetricField<Counter64> displayReadersCreated("repl.network.readersCreated", - &readersCreatedStats); -// The number and time spent reading batches off the network -TimerStats getmoreReplStats; -ServerStatusMetricField<TimerStats> displayBatchesRecieved("repl.network.getmores", - &getmoreReplStats); -// The oplog entries read via the oplog reader -Counter64 opsReadStats; -ServerStatusMetricField<Counter64> displayOpsRead("repl.network.ops", &opsReadStats); -// The bytes read via the oplog reader -Counter64 networkByteStats; -ServerStatusMetricField<Counter64> displayBytesRead("repl.network.bytes", &networkByteStats); - } // namespace StatusWith<OplogFetcher::DocumentsInfo> OplogFetcher::validateDocuments( @@ -254,7 +257,6 @@ OplogFetcher::OplogFetcher(executor::TaskExecutor* executor, _source(source), _nss(nss), _metadataObject(uassertStatusOK(makeMetadataObject(config.getProtocolVersion() == 1LL))), - _remoteCommandTimeout(config.getElectionTimeoutPeriod()), _maxFetcherRestarts(maxFetcherRestarts), _dataReplicatorExternalState(dataReplicatorExternalState), _enqueueDocumentsFn(enqueueDocumentsFn), @@ -353,10 +355,6 @@ BSONObj OplogFetcher::getMetadataObject_forTest() const { return _metadataObject; } -Milliseconds OplogFetcher::getRemoteCommandTimeout_forTest() const { - return _remoteCommandTimeout; -} - Milliseconds OplogFetcher::getAwaitDataTimeout_forTest() const { return _awaitDataTimeout; } @@ -569,7 +567,7 @@ std::unique_ptr<Fetcher> OplogFetcher::_makeFetcher(OpTime lastFetchedOpTime) { makeFindCommandObject(_dataReplicatorExternalState, _nss, lastFetchedOpTime), stdx::bind(&OplogFetcher::_callback, this, stdx::placeholders::_1, stdx::placeholders::_3), _metadataObject, - _remoteCommandTimeout); + kOplogQueryNetworkTimeout); } bool OplogFetcher::_isShuttingDown() const { diff --git a/src/mongo/db/repl/oplog_fetcher.h b/src/mongo/db/repl/oplog_fetcher.h index 0078471bf85..e87e18a41ce 100644 --- a/src/mongo/db/repl/oplog_fetcher.h +++ b/src/mongo/db/repl/oplog_fetcher.h @@ -252,7 +252,6 @@ private: const HostAndPort _source; const NamespaceString _nss; const BSONObj _metadataObject; - const Milliseconds _remoteCommandTimeout; // Maximum number of times to consecutively restart the fetcher on non-cancellation errors. const std::size_t _maxFetcherRestarts; diff --git a/src/mongo/db/repl/oplog_fetcher_test.cpp b/src/mongo/db/repl/oplog_fetcher_test.cpp index 1c77b47bd3e..b8c8f60440e 100644 --- a/src/mongo/db/repl/oplog_fetcher_test.cpp +++ b/src/mongo/db/repl/oplog_fetcher_test.cpp @@ -419,21 +419,6 @@ TEST_F(OplogFetcherTest, MetadataObjectIsEmptyUnderProtocolVersion0) { metadataObj); } -TEST_F(OplogFetcherTest, RemoteCommandTimeoutShouldEqualElectionTimeout) { - auto config = _createConfig(true); - auto timeout = OplogFetcher(&getExecutor(), - lastFetched, - source, - nss, - config, - 0, - dataReplicatorExternalState.get(), - enqueueDocumentsFn, - [](Status, OpTimeWithHash) {}) - .getRemoteCommandTimeout_forTest(); - ASSERT_EQUALS(config.getElectionTimeoutPeriod(), timeout); -} - TEST_F(OplogFetcherTest, AwaitDataTimeoutShouldEqualHalfElectionTimeoutUnderProtocolVersion1) { auto config = _createConfig(true); auto timeout = OplogFetcher(&getExecutor(), |