[SERVER-67363] $indexStats aggregations seem to increment the top counter twice Created: 17/Jun/22  Updated: 29/Oct/23  Resolved: 13/Sep/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Charlie Swanson Assignee: Ivan Fefer
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by COMPASS-6122 Investigate changes in SERVER-67363: ... Closed
Documented
is documented by DOCS-15626 Investigate changes in SERVER-67363: ... Closed
Related
related to SERVER-69660 Enable jstests/core/top.js in core_co... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: QE 2022-09-19
Participants:

 Description   

This addition to jstests/core/top.js seems to cause it to fail:

diff --git a/jstests/core/top.js b/jstests/core/top.js
index 20630f274c9..490865442e5 100644
--- a/jstests/core/top.js
+++ b/jstests/core/top.js
@@ -125,11 +125,19 @@ for (i = 0; i < numRecords; i++) {
 }
 lastTop = assertTopDiffEq(testColl, lastTop, "commands", numRecords);
 
+// aggregate
+assert.eq(0, testColl.aggregate([]).itcount());  // All records were just deleted.
+lastTop = assertTopDiffEq(testColl, lastTop, "commands", 1);
+
 // getIndexes
 assert.eq(1, testColl.getIndexes().length);
 assertTopDiffEq(testColl, lastTop, "commands", 1);
 lastTop = assertTopDiffEq(testColl, lastTop, "readLock", 1);
 
+// aggregate with $indexStats
+assert.eq(1, testColl.aggregate([{$indexStats: {}}]).itcount());
+lastTop = assertTopDiffEq(testColl, lastTop, "commands", 1);
+
 // createIndex

Specifically, that last assertion fails since "commands" is incremented by 2 instead of 1.



 Comments   
Comment by Githook User [ 13/Sep/22 ]

Author:

{'name': 'Ivan Fefer', 'email': 'ivan.fefer@mongodb.com', 'username': 'Fefer-Ivan'}

Message: SERVER-67363 Ensure aggregation with $indexStats stage only increments top counters once
Branch: master
https://github.com/mongodb/mongo/commit/07a062b64ab620ed4b2d896eabf9c22b783d5228

Comment by Charlie Swanson [ 17/Jun/22 ]

I encountered and debugged this while implementing SERVER-63947, but have since worked around it so I see no particular priority on this issue. May be a decent "neweng" ticket.

Generated at Thu Feb 08 06:07:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.