diff options
author | Benety Goh <benety@mongodb.com> | 2022-04-29 08:54:15 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-05-06 10:35:24 +0000 |
commit | 8f2a387c7276734ef35daa463abfd1d16dfce6ad (patch) | |
tree | 2e2ef59e98280d192d80e64a6997fe638cf6a0df | |
parent | 72852f034f3d7cfb21428a440dbf966a61170e9c (diff) | |
download | mongo-8f2a387c7276734ef35daa463abfd1d16dfce6ad.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.js | 10 | ||||
-rw-r--r-- | src/mongo/db/index/index_access_method.cpp | 9 |
2 files changed, 18 insertions, 1 deletions
diff --git a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js index 044558a5b27..5c7859149b0 100644 --- a/jstests/noPassthrough/serverstatus_indexbulkbuilder.js +++ b/jstests/noPassthrough/serverstatus_indexbulkbuilder.js @@ -14,6 +14,7 @@ load('jstests/noPassthrough/libs/index_build.js'); const replSet = new ReplSetTest({ nodes: 1, + nodeOptions: {setParameter: {maxIndexBuildMemoryUsageMegabytes: 50}}, }); replSet.startSet(); replSet.initiate(); @@ -25,7 +26,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), })); } @@ -38,6 +39,8 @@ assert(serverStatus.hasOwnProperty('indexBulkBuilder'), let indexBulkBuilderSection = serverStatus.indexBulkBuilder; assert.eq(indexBulkBuilderSection.count, 1, tojson(indexBulkBuilderSection)); assert.eq(indexBulkBuilderSection.resumed, 0, tojson(indexBulkBuilderSection)); +assert.eq(indexBulkBuilderSection.filesOpenedForExternalSort, 1, tojson(indexBulkBuilderSection)); +assert.eq(indexBulkBuilderSection.filesClosedForExternalSort, 1, tojson(indexBulkBuilderSection)); // Shut down server during an index to verify 'resumable' value on restart. IndexBuildTest.pauseIndexBuilds(primary); @@ -60,6 +63,11 @@ ResumableIndexBuildTest.assertCompleted(primary, coll, [buildUUID], ['a_1', 'b_1 indexBulkBuilderSection = testDB.serverStatus().indexBulkBuilder; assert.eq(indexBulkBuilderSection.count, 1, tojson(indexBulkBuilderSection)); assert.eq(indexBulkBuilderSection.resumed, 1, tojson(indexBulkBuilderSection)); +// Even though the amount of index data for b_1 is well under the configured memory usage limit, +// the resumable index build logic dictates that we spill the sorter data to disk on shutdown +// and read it back on startup. +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 563c799251d..63148efb8cf 100644 --- a/src/mongo/db/index/index_access_method.cpp +++ b/src/mongo/db/index/index_access_method.cpp @@ -97,6 +97,8 @@ public: BSONObjBuilder builder; builder.append("count", count.loadRelaxed()); builder.append("resumed", resumed.loadRelaxed()); + builder.append("filesOpenedForExternalSort", sorterFileStats.opened.loadRelaxed()); + builder.append("filesClosedForExternalSort", sorterFileStats.closed.loadRelaxed()); return builder.obj(); } @@ -106,6 +108,12 @@ public: // Number of times the bulk builder was created for a resumable index build. // This value should not exceed 'count'. AtomicWord<long long> resumed; + + // 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; /** @@ -124,6 +132,7 @@ SortOptions makeSortOptions(size_t maxMemoryUsageBytes, StringData dbName) { .TempDir(storageGlobalParams.dbpath + "/_tmp") .ExtSortAllowed() .MaxMemoryUsageBytes(maxMemoryUsageBytes) + .FileStats(&indexBulkBuilderSSS.sorterFileStats) .DBName(dbName.toString()); } |