-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Internal Code, Replication
-
ALL
Here is a jstest to show it:
/** * 1. check top numbers are correct */ var name = "toptest"; load("jstests/replsets/rslib.js"); var replTest = new ReplSetTest( {name: name, nodes: 1} ); var nodes = replTest.startSet(); var config = replTest.getReplSetConfig(); replTest.initiate(config); var master = replTest.getMaster(); wait(function() { var result = master.getDB("admin").runCommand({replSetGetStatus:1}); return result.members && result.members[0].state == 1; }); var testDB = master.getDB(name); var testColl = testDB[name + "coll"] var topResult = testDB.adminCommand("top"); printjson(topResult.totals[testColl.getFullName()]); var inserts = 0; for(i=0;i<20;i++) { testColl.insert({_id:i}); inserts++; } var topResult = testDB.adminCommand("top"); print("inserted " + inserts) printjson(topResult.totals[testColl.getFullName()]); //verify only 20 inserts took place assert(inserts, topResult.totals[testColl.getFullName()].insert.count); replTest.stopSet();
Here is another to add for the non-rs case:
/** * 1. check top numbers are correct */ var name = "toptest"; var testDB = db.getSiblingDB(name); var testColl = testDB[name + "coll"] testColl.drop() var topResult = testDB.adminCommand("top"); printjson(topResult.totals[testColl.getFullName()]); var inserts = 0; for(i=0;i<20;i++) { testColl.insert({_id:i}); inserts++; } var topResult = testDB.adminCommand("top"); print("inserted " + inserts) printjson(topResult.totals[testColl.getFullName()]); //verify only 20 inserts took place assert(inserts, topResult.totals[testColl.getFullName()].insert.count); testColl.drop()