diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2020-02-09 23:05:56 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-11 16:58:42 +0000 |
commit | faa931d0c180e16c8a249142a657cfd5fe3af2bb (patch) | |
tree | 29cbddd81be20979da7c1480fed4a64b3054d556 /src/mongo/db | |
parent | 33d5b7aedebf73f581a87880f0872cbb54bf6539 (diff) | |
download | mongo-faa931d0c180e16c8a249142a657cfd5fe3af2bb.tar.gz |
SERVER-44705: Track time spent in each batch
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_fetcher.h | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/db/repl/oplog_fetcher.cpp b/src/mongo/db/repl/oplog_fetcher.cpp index f6006f67ed2..7f7e8c11d0d 100644 --- a/src/mongo/db/repl/oplog_fetcher.cpp +++ b/src/mongo/db/repl/oplog_fetcher.cpp @@ -940,6 +940,7 @@ void NewOplogFetcher::_createNewCursor(bool initialFind) { StatusWith<NewOplogFetcher::Documents> NewOplogFetcher::_getNextBatch() { Documents batch; try { + Timer timer; // If it is the first batch, we should initialize the cursor, which will run the find query. // Otherwise we should call more() to get the next batch. if (_firstBatch) { @@ -972,6 +973,10 @@ StatusWith<NewOplogFetcher::Documents> NewOplogFetcher::_getNextBatch() { while (_cursor->moreInCurrentBatch()) { batch.emplace_back(_cursor->nextSafe()); } + + // This value is only used on a successful batch for metrics.repl.network.getmores. This + // metric intentionally tracks the time taken by the initial find as well. + _lastBatchElapsedMS = timer.millis(); } catch (const DBException& ex) { if (_cursor->connectionHasPendingReplies()) { // Close the connection because the connection cannot be used anymore as more data is on @@ -1084,7 +1089,7 @@ Status NewOplogFetcher::_onSuccessfulBatch(const Documents& documents) { opsReadStats.increment(info.networkDocumentCount); networkByteStats.increment(info.networkDocumentBytes); - // TODO SERVER-44705: Track time spent in each batch. + getmoreReplStats.recordMillis(_lastBatchElapsedMS); auto status = _enqueueDocumentsFn(firstDocToApply, documents.cend(), info); if (!status.isOK()) { diff --git a/src/mongo/db/repl/oplog_fetcher.h b/src/mongo/db/repl/oplog_fetcher.h index 0ee841bd6ba..0c64c44ede3 100644 --- a/src/mongo/db/repl/oplog_fetcher.h +++ b/src/mongo/db/repl/oplog_fetcher.h @@ -597,6 +597,8 @@ private: // Handle to currently scheduled _runQuery task. executor::TaskExecutor::CallbackHandle _runQueryHandle; + + int _lastBatchElapsedMS; }; } // namespace repl |