[SERVER-21976] dataSize cmd should ignore current database in mongos Created: 21/Dec/15  Updated: 16/Mar/16  Resolved: 08/Mar/16

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: 3.3.3

Type: Improvement Priority: Major - P3
Reporter: Kyle Suarez Assignee: Dianna Hohensee (Inactive)
Resolution: Done Votes: 0
Labels: command, mongos, neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to DOCS-5076 Comment on: "manual/tutorial/merge-ch... Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 11 (03/11/16)
Participants:

 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
}



 Comments   
Comment by Githook User [ 08/Mar/16 ]

Author:

{u'username': u'DiannaHohensee', u'name': u'Dianna Hohensee', u'email': u'dianna.hohensee@10gen.com'}

Message: SERVER-21976 fixing mongos' routing of dataSize command to mongods: it was using the wrong database
Branch: master
https://github.com/mongodb/mongo/commit/730b0cd2f42b69e54c2178bf05858d13e099a274

Comment by Githook User [ 08/Jan/16 ]

Author:

{u'username': u'ksuarz', u'name': u'Kyle Suarez', u'email': u'kyle.suarez@mongodb.com'}

Message: DOCS-5076 must use database before dataSize cmd

When connected to a mongos, the `dataSize` command must be run in the context of
the database containing the collection to measure.

See SERVER-21976.

Signed-off-by: Andrew Aldridge <i80and@foxquill.com>
Branch: master
https://github.com/mongodb/docs/commit/0ad138f255554ff9b02727027f7cd156860c16fa

Comment by Kyle Suarez [ 22/Dec/15 ]

Awesome, thanks. The documentation page for dataSize is here; I don't think it requires updating but I can refactor it if the sharding team thinks it needs to be revisited.

Comment by Kelsey Schubert [ 22/Dec/15 ]

Thanks Kyle - I'm sending this to the sharding team to triage.

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