...
In three additional cases (beyond the ones described in SERVER-35479 and SERVER-35522) the results of collStats depends on the topology of the server. Currently, if one attaches to a standalone instance of mongo, one will receive the NamespaceNotFound error code if one asks for collStats with the queryExecStats or storageStats options on a namespace that doesn't exist (e.g. "dne"). Additionally, one will receive a numeric error code if one passes an unknown option (e.g. "unknown"). However, if one connects to a mongos the NamespaceNotFound errors will be suppressed by the mongos instance if one pass such options to a namespace that doesn't exist. Additionally, because we don't validate that the options passed to collStats are correct when we do a "light parse" of the pipeline we actually get a NamespaceNotFound error when we get the routing info which then gets suppressed by the same code path if one asks for collStats on a collection that doesn't exist with an unknown option. Resolution of this ticket should include: 1) Stopping mongos from suppressing namespace not found errors. 2) Ensuring that mongos produces an option validation error before a namespace not found error in the event of unknown options being passed to a collStats stage being run on a nonexistent namespace. 3) Tests to verify that collStats behaves correctly regardless of topology.
xgen-internal-githook commented on Tue, 23 Mar 2021 00:54:24 +0000: Author: {'name': 'ruslan.abdulkhalikov', 'email': 'ruslan.abdulkhalikov@mongodb.com', 'username': 'rusabd1'} Message: SERVER-53083 collStats results depend on topology and option Branch: master https://github.com/mongodb/mongo/commit/20c01a9f4cd201662f9d67f3974fd85df0979186 JIRAUSER1258164 commented on Thu, 7 Jan 2021 19:05:07 +0000: Still trying to get my first build. But sure! via [1]Newton Mail On Thu, Jan 7, 2021 at 10:49 AM, Charlie Swanson (Jira) wrote: Message Title [2]Charlie Swanson assigned an issue to [3]Joel Redman [4]Joel Redman I'm assigning this to you to track for the next sprint. Please take a look after you get to a good stopping point and/or blocked with your current ticket. [5]Core Server / [6][7]SERVER-53083 [8]collStats results depend on topology and option. Change By: [9]Charlie Swanson Sprint: Query 2020-12-28, Query 2021-01- 11 25 Assignee: Backlog - Query Optimization Joel Redman [10] [11]Add Comment This message was sent from MongoDB's issue tracking system. To respond to this ticket, please login to [12]jira.mongodb.org using your JIRA, MongoDB Cloud Manager, or MongoDB Atlas credentials. ---------------------------------------------------------------------------------------- [1] https://cloudmagic.com/k/d/mailapp?ct=pi&cv=10.0.53&pv=14.2&source=email_footer_2 [2] https://jira.mongodb.org/secure/ViewProfile.jspa?name=charlie.swanson [3] https://jira.mongodb.org/secure/ViewProfile.jspa?name=joel.redman [4] https://jira.mongodb.org/secure/ViewProfile.jspa?name=joel.redman [5] https://jira.mongodb.org/browse/SERVER [6] https://jira.mongodb.org/browse/SERVER-53083 [7] https://jira.mongodb.org/browse/SERVER-53083 [8] https://jira.mongodb.org/browse/SERVER-53083 [9] https://jira.mongodb.org/secure/ViewProfile.jspa?name=charlie.swanson [10] https://jira.mongodb.org/browse/SERVER-53083#add-comment [11] https://jira.mongodb.org/browse/SERVER-53083#add-comment [12] https://jira.mongodb.org charlie.swanson commented on Thu, 7 Jan 2021 18:48:58 +0000: joel.redman I'm assigning this to you to track for the next sprint. Please take a look after you get to a good stopping point and/or blocked with your current ticket.
1) Setup a mongod instance. 2) Connect to the mongod instance and run the following commands producing the following output: > db.runCommand({aggregate: "dne", pipeline:[{"$collStats": {"unknown": {}}}], cursor:{}}) { "ok" : 0, "errmsg" : "unrecognized option to $collStats: unknown", "code" : 40168, "codeName" : "Location40168" } > db.runCommand({aggregate: "dne", pipeline:[{"$collStats": {"queryExecStats": {}}}], cursor:{}}) { "ok" : 0, "errmsg" : "PlanExecutor error during aggregation :: caused by :: Unable to retrieve queryExecStats in $collStats stage :: caused by :: Collection [test.dne] not found.", "code" : 26, "codeName" : "NamespaceNotFound" } > db.runCommand({aggregate: "dne", pipeline:[{"$collStats": {"storageStats": {}}}], cursor:{}}) { "ok" : 0, "errmsg" : "PlanExecutor error during aggregation :: caused by :: Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [test.dne] not found.", "code" : 26, "codeName" : "NamespaceNotFound" } 3) Start a sharded cluster (e.g. by running let st = ShardingTest({shards: 2}) in the mongo shell with the `--nodb` option). 4) Connect to the mongos and run the following commands producing the following results: (if you use `ShardingTest` to start the sharded cluster the mongos should be on port 20005) mongos> db.runCommand({aggregate: "dne", pipeline:[{"$collStats": {"unknown": {}}}], cursor:{}}) { "result" : [ ], "cursor" : { "id" : NumberLong(0), "ns" : "test.dne", "firstBatch" : [ ] }, "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1606339832, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1606339832, 1) } mongos> db.runCommand({aggregate: "dne", pipeline:[{"$collStats": {"queryExecStats": {}}}], cursor:{}}) { "result" : [ ], "cursor" : { "id" : NumberLong(0), "ns" : "test.dne", "firstBatch" : [ ] }, "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1606339835, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1606339835, 1) } mongos> db.runCommand({aggregate: "dne", pipeline:[{"$collStats": {"storageStats": {}}}], cursor:{}}) { "result" : [ ], "cursor" : { "id" : NumberLong(0), "ns" : "test.dne", "firstBatch" : [ ] }, "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1606339835, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1606339835, 1) }