[SERVER-1134] Increments due to running admin commands Created: 18/May/10  Updated: 12/Jul/16  Resolved: 26/May/10

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 1.4.2
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Justin Smestad Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

When running db._adminCommand('top') it seems that the values that get sent back are effected by the command. Meaning, I could have 10 queries on a particular collection before running the top command, however after running the top command it jumps up a large amount (have not tested for the exact amount) to something like 120 queries.

I spoke with Kyle regarding this and he asked me to open an issue since it may be a bug. We are trying to figure out what and how many times a collection is 'touched' when top is run on the server.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 26/May/10 ]

$cmd is all db commands, including top itself.

you may want to remove that from your counts

Comment by Paul Sadauskas [ 20/May/10 ]

I'm trying to get some more information about this. I'm pretty sure its just a misunderstanding on our end, but I'm having trouble finding docs on what the top command returns. Here's what I've collected:

> use mongo_stats
switched to db mongo_stats
> show collections
log
raw
system.indexes
system.users
> use admin
> db.runCommand(

{top: true}

).totals["mongo_stats.raw"]["queries"]

{ "time" : 18873, "count" : 4 }

> db.runCommand(

{top: true}

).totals["mongo_stats.log"]["queries"]

{ "time" : 0, "count" : 0 }

> db.runCommand(

{top: true}

).totals["mongo_stats.system.users"]["queries"]

{ "time" : 1638, "count" : 20 }

> db.runCommand(

{top: true}

).totals["mongo_stats.$cmd"]["queries"]

{ "time" : 49880, "count" : 43 }

> db.runCommand(

{top: true}

).totals["mongo_stats"]["queries"]

{ "time" : 9790, "count" : 21 }

( http://gist.github.com/407198 if the formatting blows up)

What is the $cmd "collection", and what is the last one, with no collection? What commands increment the counters for those stats?

The original issue is incorrectly defined, thats not the behavior we're seeing. I've written a script that runs as a cronjob, which takes every entry in runCommand(

{top: true}

)["totals"] and inserts it into a separate db. The cron job runs every 2 minutes, and we have 150 entries in the result of top. However, over the last 3 days, it has done nearly 2 _B_illion requests on that database. I would expect something closer to ( 30 runs/hr * 24h * 3d * 150 results = 300,000 inserts)

Here's the client debug log file of a single run: https://gist.github.com/db1e5cfd85ec6efd4d07 .
$ cat statdumper.log | grep insert | wc -l
155

In this screenshot, you can see the results from top: http://skitch.com/theamazingrando/drmac/hosted-mongodb-from-mongo-machine
The $cmd entry that top reports is not in here, but it does get included in my total, and you can see that there's about 200,000 "queries" to the $cmd database. I'm not sure where the removes come from, the script doesn't do any removes.

I guess my biggest question is: What exactly does top report?

Comment by Eliot Horowitz (Inactive) [ 19/May/10 ]

can you provide an example?
we use that a lot and have never seen any such behavior

Generated at Thu Feb 08 02:56:10 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.