[SERVER-7550] top collection stats include oplog ops (inserts) Created: 05/Nov/12  Updated: 15/Aug/18  Resolved: 15/Aug/18

Status: Closed
Project: Core Server
Component/s: Internal Code, Replication
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Asya Kamsky
Resolution: Done Votes: 1
Labels: metrics, stats, wg
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

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



 Comments   
Comment by Asya Kamsky [ 15/Aug/18 ]

I just tested this on 4.0 and master and the current behavior of the provided test is correct - top shows the same on standalone and replica set in this test.  t0 is output of db.adminCommand('top') before the 20 inserts loop, t1 is after.

// on replica set primary
t0.totals["test.test"].insert
{ "time" : 0, "count" : 0 }
t1.totals["test.test"].insert
{ "time" : 15295, "count" : 20 }
 
// on standalone
t0.totals["test.test"].insert
{ "time" : 0, "count" : 0 }
test@127.0.0.1:27017(4.0.0) > t1.totals["test.test"].insert
{ "time" : 18725, "count" : 20 }

Comment by Scott Hernandez (Inactive) [ 05/Nov/12 ]

Here is the output to the rs test:

inserted 20
{
	"total" : {
		"time" : 102165,
		"count" : 40
	},
	"readLock" : {
		"time" : 0,
		"count" : 0
	},
	"writeLock" : {
		"time" : 102165,
		"count" : 40
	},
	"queries" : {
		"time" : 0,
		"count" : 0
	},
	"getmore" : {
		"time" : 0,
		"count" : 0
	},
	"insert" : {
		"time" : 102165,
		"count" : 40
	},
	"update" : {
		"time" : 0,
		"count" : 0
	},
	"remove" : {
		"time" : 0,
		"count" : 0
	},
	"commands" : {
		"time" : 0,
		"count" : 0
	}
}

Generated at Thu Feb 08 03:14:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.