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

dataSize cmd should ignore current database in mongos

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3.3
    • Component/s: Sharding
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      Sharding 11 (03/11/16)

      Description

      When running dataSize in a mongos, the command only works when the current database matches the database of the collection whose size you're trying to measure.

      For example, if I have a collection test.users, this works:

      mongos> use test
      switched to db test
      mongos> db.runCommand({"dataSize": "test.users", "keyPattern": {"username": 1}, "min": {"username": 0}, "max": {"username": 7000}})
      { "size" : 200000, "numObjects" : 5000, "millis" : 5, "ok" : 1 }
      

      However, if the current database is not test, then the shell erroneously reports that the collection is empty:

      mongos> use admin
      switched to db admin
      mongos> db.runCommand({"dataSize": "test.users", "keyPattern": {"username": 1}, "min": {"username": 0}, "max": {"username": 7000}})
      { "size" : 0, "numObjects" : 0, "millis" : 0, "ok" : 1 }
      

      Since the full namespace is required for the command, it makes no sense to consider the currently active database.

      This problem only occurs when connected to a mongos. If I connect directly to a mongod, dataSize correctly gives me the collection size no matter what the currently active database is:

      > use admin
      switched to db admin
      > db.runCommand({"dataSize": "test.users", "keyPattern": {"username": 1}, "min": {"username": 0}, "max": {"username": 7000}})
      {
              "estimate" : false,
              "size" : 960,
              "numObjects" : 24,
              "millis" : 0,
              "ok" : 1
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dianna.hohensee Dianna Hohensee
              Reporter:
              kyle.suarez Kyle Suarez
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: