summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2022-08-27 07:32:45 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-27 11:57:35 +0000
commit8feeb48360ee87f396068ffe00cc1a5d7282e2e0 (patch)
tree1e8cb1f82a0ab1b2ea935c1571ff2e1b20090ad2
parent8dd7f66d46cead919bbe13554c3543d16b16a385 (diff)
downloadmongo-8feeb48360ee87f396068ffe00cc1a5d7282e2e0.tar.gz
SERVER-64659 add external sorter file handle metrics to indexBulkBuilder server status section
(cherry picked from commit bfc606f1cc5ad931f054b5c152993a57d30eef64)
-rw-r--r--jstests/noPassthrough/serverstatus_indexbulkbuilder.js5
-rw-r--r--src/mongo/db/index/index_access_method.cpp9
2 files changed, 13 insertions, 1 deletions
diff --git a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js
index 780033e4e62..d42ae64db58 100644
--- a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js
+++ b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js
@@ -12,6 +12,7 @@
const replSet = new ReplSetTest({
nodes: 1,
+ nodeOptions: {setParameter: {maxIndexBuildMemoryUsageMegabytes: 50}},
});
replSet.startSet();
replSet.initiate();
@@ -23,7 +24,7 @@ let coll = testDB.getCollection('t');
for (let i = 0; i < 10; i++) {
assert.commandWorked(coll.insert({
_id: i,
- a: i,
+ a: 'a'.repeat(10 * 1024 * 1024),
}));
}
@@ -35,6 +36,8 @@ assert(serverStatus.hasOwnProperty('indexBulkBuilder'),
let indexBulkBuilderSection = serverStatus.indexBulkBuilder;
assert.eq(indexBulkBuilderSection.count, 1, tojson(indexBulkBuilderSection));
+assert.eq(indexBulkBuilderSection.filesOpenedForExternalSort, 4, tojson(indexBulkBuilderSection));
+assert.eq(indexBulkBuilderSection.filesClosedForExternalSort, 4, tojson(indexBulkBuilderSection));
replSet.stopSet();
})();
diff --git a/src/mongo/db/index/index_access_method.cpp b/src/mongo/db/index/index_access_method.cpp
index cde0fbaa055..b1fccf76307 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -96,11 +96,19 @@ public:
BSONObj generateSection(OperationContext* opCtx, const BSONElement& configElement) const final {
BSONObjBuilder builder;
builder.append("count", count.loadRelaxed());
+ builder.append("filesOpenedForExternalSort", sorterFileStats.opened.loadRelaxed());
+ builder.append("filesClosedForExternalSort", sorterFileStats.closed.loadRelaxed());
return builder.obj();
}
// Number of instances of the bulk builder created.
AtomicWord<long long> count;
+
+ // Number of times the external sorter opened/closed a file handle to spill data to disk.
+ // This pair of counters in aggregate indicate the number of open file handles used by
+ // the external sorter and may be useful in diagnosing situations where the process is
+ // close to exhausting this finite resource.
+ SorterFileStats sorterFileStats;
} indexBulkBuilderSSS;
/**
@@ -630,6 +638,7 @@ AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(const IndexAccessMet
SortOptions()
.TempDir(storageGlobalParams.dbpath + "/_tmp")
.ExtSortAllowed()
+ .FileStats(&indexBulkBuilderSSS.sorterFileStats)
.MaxMemoryUsageBytes(maxMemoryUsageBytes),
BtreeExternalSortComparison(descriptor->keyPattern(), descriptor->version()))),
_real(index) {