Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-7550

top collection stats include oplog ops (inserts)

    • 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()
      

            Assignee:
            asya.kamsky@mongodb.com Asya Kamsky
            Reporter:
            scotthernandez Scott Hernandez (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: