[SERVER-4795] Mongostat opcount varies with sleep time when polling multiple hosts Created: 27/Jan/12  Updated: 11/Jul/16  Resolved: 08/Dec/12

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 2.0.2
Fix Version/s: 2.3.2

Type: Bug Priority: Major - P3
Reporter: Barrie Segal Assignee: Shaun Verch
Resolution: Done Votes: 1
Labels: mongostat, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Participants:

 Description   

When mongostat is run with multiple hosts (either with the --discover flag or -h), the number of operations appears to be divided by the sleep time.

To reproduce:

Here is a JS function that will insert 100 records per second for a minute:

> for(var i=0; i<60; i++){for(var j = 0; j<100; j++){db.stattest.save({t:i, x:j})};sleep(1000);}

While the above is running, run mongostat with the following options:

$ bin/mongostat -h localhost,127.0.0.1 5
insert query update delete getmore command flushes mapped vsize res locked % idx miss % qr|qw ar|aw netIn netOut conn time
127.0.0.1:27017 20 0 0 0 0 1 0 464m 3.35g 9m 0.1 0 0|0 0|0 1k 1k 8 11:56:23
localhost 20 0 0 0 0 1 0 464m 3.35g 9m 0.1 0 0|0 0|0 1k 1k 8 11:56:23

Notice that the number of inserts is 20 (100/5). The same can be observed with using --discover:

$ bin/mongostat --discover 5
insert query update delete getmore command flushes mapped vsize res locked % idx miss % qr|qw ar|aw netIn netOut conn time
localhost:27017 20 0 0 0 0 1 0 464m 3.35g 8m 0.2 0 0|0 0|0 1k 1k 8 11:56:45

If an interval of 10seconds is used, the "inserts" count changes to 10 (100/10):
$ bin/mongostat --discover 10
connected to: 127.0.0.1

insert query update delete getmore command flushes mapped vsize res locked % idx miss % qr|qw ar|aw netIn netOut conn time
localhost:27017 10 0 0 0 0 0 0 464m 3.35g 5m 0.3 0 0|0 0|0 817b 787b 8 11:54:24

The work-around is to poll only one host at a time, or poll multiple hosts with no delay. (In the second case, the division will still occur, but it will be by 1.)



 Comments   
Comment by auto [ 08/Dec/12 ]

Author:

{u'date': u'2012-11-28T01:05:47Z', u'name': u'Shaun Verch', u'email': u'shaun.verch@10gen.com'}

Message: SERVER-4795 mongostat sleep for correct amount of time when multiple hosts specified
Branch: master
https://github.com/mongodb/mongo/commit/c36b02cac2131f7beb73fdb8c7dcb7ec6ce6787c

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