diff options
-rw-r--r-- | jstests/noPassthrough/serverstatus_indexbulkbuilder.js | 5 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 11 |
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>( |