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

Queries are not recorded in top stats when run in a script

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • ALL
    • Hide

      As a script:

      [sv@sv ~/dev/mongodb_repos/SERVER-7774 (master)]$ mongo testfile.js
      MongoDB shell version: 2.3.3-pre-
      connecting to: test
      { "time" : 0, "count" : 0 }
      

      In the shell:

      [sv@sv ~/dev/mongodb_repos/SERVER-7774 (master)]$ cat testfile.js
      db.test.drop();
      db.test.insert({x:1});
      db.test.find({x:1});
      db.test.find({x:1});
      db.test.find({x:1});
      printjson(db.adminCommand("top").totals["test.test"].queries);
      [sv@sv ~/dev/mongodb_repos/SERVER-7774 (master)]$ mongo
      MongoDB shell version: 2.3.3-pre-
      connecting to: test
      Server has startup warnings:
      Mon Apr  8 13:38:23.719 [initandlisten]
      Mon Apr  8 13:38:23.719 [initandlisten] ** NOTE: This is a development version (2.5.0-pre-) of MongoDB.
      Mon Apr  8 13:38:23.719 [initandlisten] **       Not recommended for production.
      Mon Apr  8 13:38:23.719 [initandlisten]
      > db.test.drop();
      true
      > db.test.insert({x:1});
      > db.test.find({x:1});
      { "_id" : ObjectId("516343b8a4cd2ac566f62971"), "x" : 1 }
      > db.test.find({x:1});
      { "_id" : ObjectId("516343b8a4cd2ac566f62971"), "x" : 1 }
      > db.test.find({x:1});
      { "_id" : ObjectId("516343b8a4cd2ac566f62971"), "x" : 1 }
      > printjson(db.adminCommand("top").totals["test.test"].queries);
      { "time" : 200, "count" : 2 }
      >
      bye
      
      Show
      As a script: [sv@sv ~/dev/mongodb_repos/SERVER-7774 (master)]$ mongo testfile.js MongoDB shell version: 2.3.3-pre- connecting to: test { "time" : 0, "count" : 0 } In the shell: [sv@sv ~/dev/mongodb_repos/SERVER-7774 (master)]$ cat testfile.js db.test.drop(); db.test.insert({x:1}); db.test.find({x:1}); db.test.find({x:1}); db.test.find({x:1}); printjson(db.adminCommand( "top" ).totals[ "test.test" ].queries); [sv@sv ~/dev/mongodb_repos/SERVER-7774 (master)]$ mongo MongoDB shell version: 2.3.3-pre- connecting to: test Server has startup warnings: Mon Apr 8 13:38:23.719 [initandlisten] Mon Apr 8 13:38:23.719 [initandlisten] ** NOTE: This is a development version (2.5.0-pre-) of MongoDB. Mon Apr 8 13:38:23.719 [initandlisten] ** Not recommended for production. Mon Apr 8 13:38:23.719 [initandlisten] > db.test.drop(); true > db.test.insert({x:1}); > db.test.find({x:1}); { "_id" : ObjectId( "516343b8a4cd2ac566f62971" ), "x" : 1 } > db.test.find({x:1}); { "_id" : ObjectId( "516343b8a4cd2ac566f62971" ), "x" : 1 } > db.test.find({x:1}); { "_id" : ObjectId( "516343b8a4cd2ac566f62971" ), "x" : 1 } > printjson(db.adminCommand( "top" ).totals[ "test.test" ].queries); { "time" : 200, "count" : 2 } > bye

      Queries are recorded differently in the top stats depending on whether they are run from a script or from the shell. I posted an example of running the same test in both places with different results.

            Assignee:
            Unassigned Unassigned
            Reporter:
            sverch Shaun Verch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: