summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2022-04-29 08:54:15 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-06-25 11:51:07 +0000
commit32aff083f4698a2632f8a7037ce4150afa958e90 (patch)
treeff0bf7bcfd59e5750b92e56c113e439debff6c03
parente163059b8d3d069d52a251970266cedc4a12fb54 (diff)
downloadmongo-32aff083f4698a2632f8a7037ce4150afa958e90.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.cpp11
2 files changed, 14 insertions, 2 deletions
diff --git a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js
index 780033e4e62..a7b6bdbec3f 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, 1, tojson(indexBulkBuilderSection));
+assert.eq(indexBulkBuilderSection.filesClosedForExternalSort, 1, 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 67b09f80563..cd098ab11d5 100644
--- a/src/mongo/db/index/index_access_method.cpp
+++ b/src/mongo/db/index/index_access_method.cpp
@@ -99,11 +99,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;
/**
@@ -562,7 +570,8 @@ AbstractIndexAccessMethod::BulkBuilderImpl::BulkBuilderImpl(IndexCatalogEntry* i
SortOptions()
.TempDir(storageGlobalParams.dbpath + "/_tmp")
.ExtSortAllowed()
- .MaxMemoryUsageBytes(maxMemoryUsageBytes),
+ .MaxMemoryUsageBytes(maxMemoryUsageBytes)
+ .FileStats(&indexBulkBuilderSSS.sorterFileStats),
BtreeExternalSortComparison(),
std::pair<KeyString::Value::SorterDeserializeSettings,
mongo::NullValue::SorterDeserializeSettings>(