summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2018-12-04 15:47:03 -0500
committerSuganthi Mani <suganthi.mani@mongodb.com>2019-01-23 11:08:09 -0500
commit1a24b7d77d1271de19b61705b3890953d485978e (patch)
tree99c74e9e89704d42f48c0279d4e042c6ea4cdbe0
parent5c7c6729c37514760fd34da462b6961a2e385417 (diff)
downloadmongo-1a24b7d77d1271de19b61705b3890953d485978e.tar.gz
SERVER-37910 Added a new serverStatus meteric "repl.apply.batchSize" to track oplog application batch size.
(cherry picked from commit cc102992f6fe9dd499edc9242b8a5be961ed35dd)
-rw-r--r--jstests/replsets/server_status_metrics.js1
-rw-r--r--src/mongo/db/repl/sync_tail.cpp12
2 files changed, 12 insertions, 1 deletions
diff --git a/jstests/replsets/server_status_metrics.js b/jstests/replsets/server_status_metrics.js
index 9b805b92e4c..59054f2172a 100644
--- a/jstests/replsets/server_status_metrics.js
+++ b/jstests/replsets/server_status_metrics.js
@@ -25,6 +25,7 @@ function testSecondaryMetrics(secondary, opCount, offset) {
assert(ss.metrics.repl.preload.docs.num >= 0, "preload.indexes num missing");
assert(ss.metrics.repl.preload.indexes.totalMillis >= 0, "preload.indexes time missing");
+ assert.eq(ss.metrics.repl.apply.batchSize, opCount + offset, "apply ops batch size mismatch");
assert(ss.metrics.repl.apply.batches.num > 0, "no batches");
assert(ss.metrics.repl.apply.batches.totalMillis >= 0, "missing batch time");
assert.eq(ss.metrics.repl.apply.ops, opCount + offset, "wrong number of applied ops");
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index a5dfbf3ebb4..306e0b4185c 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -147,6 +147,11 @@ public:
Counter64 opsAppliedStats;
ServerStatusMetricField<Counter64> displayOpsApplied("repl.apply.ops", &opsAppliedStats);
+// Tracks the oplog application batch size.
+Counter64 oplogApplicationBatchSize;
+ServerStatusMetricField<Counter64> displayOplogApplicationBatchSize("repl.apply.batchSize",
+ &oplogApplicationBatchSize);
+
// Number of times we tried to go live as a secondary.
Counter64 attemptsToBecomeSecondary;
ServerStatusMetricField<Counter64> displayAttemptsToBecomeSecondary(
@@ -350,8 +355,10 @@ Status SyncTail::syncApply(OperationContext* opCtx,
bool isNoOp = opType[0] == 'n';
if (isNoOp || (opType[0] == 'i' && nss.isSystemDotIndexes())) {
- if (isNoOp && nss.db() == "")
+ if (isNoOp && nss.db() == "") {
+ incrementOpsAppliedStats();
return Status::OK();
+ }
Lock::DBLock dbLock(opCtx, nss.db(), MODE_X);
OldClientContext ctx(opCtx, nss.ns());
return applyOp(ctx.db());
@@ -1495,6 +1502,9 @@ StatusWith<OpTime> multiApply(OperationContext* opCtx,
"attempting to replicate ops while primary"};
}
+ // Increment the batch size stat.
+ oplogApplicationBatchSize.increment(ops.size());
+
std::vector<Status> statusVector(workerPool->getNumThreads(), Status::OK());
{
// Each node records cumulative batch application stats for itself using this timer.