diff options
author | Ivan Fefer <ivan.fefer@mongodb.com> | 2022-09-13 14:15:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-09-13 14:48:54 +0000 |
commit | 07a062b64ab620ed4b2d896eabf9c22b783d5228 (patch) | |
tree | 5668317e4ccfbc6c46af08de2f0b9b39b0c20fb4 | |
parent | d26ae542584d0e4d92f1d9906e49b6f5a24d260f (diff) | |
download | mongo-07a062b64ab620ed4b2d896eabf9c22b783d5228.tar.gz |
SERVER-67363 Ensure aggregation with $indexStats stage only increments top counters once
-rw-r--r-- | jstests/core/top.js | 15 | ||||
-rw-r--r-- | src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/jstests/core/top.js b/jstests/core/top.js index 20630f274c9..6b9716b1fa5 100644 --- a/jstests/core/top.js +++ b/jstests/core/top.js @@ -14,6 +14,7 @@ * # passthrough suites automatically retry operations on TenantMigrationAborted errors. * tenant_migration_incompatible, * does_not_support_repeated_reads, + * requires_fcv_62, * ] */ @@ -125,8 +126,20 @@ for (i = 0; i < numRecords; i++) { } lastTop = assertTopDiffEq(testColl, lastTop, "commands", numRecords); +// aggregate +assert.eq(0, testColl.aggregate([]).itcount()); // All records were just deleted. +assertTopDiffEq(testColl, lastTop, "commands", 1); +lastTop = assertTopDiffEq(testColl, lastTop, "readLock", 1); + // getIndexes -assert.eq(1, testColl.getIndexes().length); +const indexes = testColl.getIndexes(); +assert.eq(1, indexes.length); +assertTopDiffEq(testColl, lastTop, "commands", 1); +lastTop = assertTopDiffEq(testColl, lastTop, "readLock", 1); + +// aggregate with $indexStats +const expectedIndexStatsCount = indexes[0].clustered ? 0 : 1; +assert.eq(expectedIndexStatsCount, testColl.aggregate([{$indexStats: {}}]).itcount()); assertTopDiffEq(testColl, lastTop, "commands", 1); lastTop = assertTopDiffEq(testColl, lastTop, "readLock", 1); diff --git a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp index 0f533f0daab..c341101d893 100644 --- a/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp +++ b/src/mongo/db/pipeline/process_interface/common_mongod_process_interface.cpp @@ -173,7 +173,7 @@ std::vector<Document> CommonMongodProcessInterface::getIndexStats(OperationConte const NamespaceString& ns, StringData host, bool addShardName) { - AutoGetCollectionForReadCommandMaybeLockFree collection(opCtx, ns); + AutoGetCollectionForReadMaybeLockFree collection(opCtx, ns); std::vector<Document> indexStats; if (!collection) { |