[SERVER-68152] explain_missing_collection.js fails when database doesn't exist Created: 19/Jul/22  Updated: 29/Oct/23  Resolved: 09/Aug/22

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Vishnu Kaushik Assignee: Erin Liang
Resolution: Fixed Votes: 0
Labels: sharding-nyc-subteam3
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Problem/Incident
causes SERVER-69398 Check filler_collection already exist... Closed
Related
related to SERVER-68273 count11.js, geo_big_polygon3.js fail ... Backlog
related to SERVER-68971 explain_distinct.js fails when databa... Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 2022-08-08, Sharding 2022-08-22
Participants:

 Description   

If no jstest ran before it, the database test will not exist when explain_missing_collection.js is run, since a previous test will not have created the database as a part of creating some other collection. This will cause the explain to fail:

[js_test:explain_missing_collection] Implicit session: session { "id" : UUID("4a1e56e2-7511-433a-a11b-81fc6009e44e") }
[js_test:explain_missing_collection] MongoDB server version: 6.0.0-rc13
[js_test:explain_missing_collection] uncaught exception: Error: explain failed: {
[js_test:explain_missing_collection] 	"ok" : 0,
[js_test:explain_missing_collection] 	"errmsg" : "database test not found",
[js_test:explain_missing_collection] 	"code" : 26,
[js_test:explain_missing_collection] 	"codeName" : "NamespaceNotFound",
[js_test:explain_missing_collection] 	"$clusterTime" : {
[js_test:explain_missing_collection] 		"clusterTime" : Timestamp(1658258619, 62),
[js_test:explain_missing_collection] 		"signature" : {
[js_test:explain_missing_collection] 			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
[js_test:explain_missing_collection] 			"keyId" : NumberLong(0)
[js_test:explain_missing_collection] 		}
[js_test:explain_missing_collection] 	},
[js_test:explain_missing_collection] 	"operationTime" : Timestamp(1658258619, 62)
[js_test:explain_missing_collection] } :
[js_test:explain_missing_collection] _getErrorWithCode@src/mongo/shell/utils.js:24:13
[js_test:explain_missing_collection] throwOrReturn@src/mongo/shell/explainable.js:25:19
[js_test:explain_missing_collection] constructor/this.finish@src/mongo/shell/explain_query.js:114:32
[js_test:explain_missing_collection] @jstests/core/explain_missing_collection.js:15:56
[js_test:explain_missing_collection] @jstests/core/explain_missing_collection.js:49:2
[js_test:explain_missing_collection] failed to load: jstests/core/explain_missing_collection.js
[js_test:explain_missing_collection] exiting with code -3

You can use this suite to reproduce the problem:

test_kind: js_test
 
selector:
  roots:
  - jstests/core/explain_missing_collection.js
 
executor:
  fixture:
    class: ShardedClusterFixture
    mongod_options:
      set_parameters:
        enableTestCommands: 1
    mongos_options:
      set_parameters:
        enableTestCommands: 1
    num_shards: 1
    num_rs_nodes_per_shard: 1

I don't know if this is a problem with the test or mongos so I'm deferring that to the Sharding Team.



 Comments   
Comment by Adi Zaimi [ 02/Sep/22 ]

Fixing in https://jira.mongodb.org/browse/SERVER-68971.

Comment by Adi Zaimi [ 02/Sep/22 ]

I can't think of a generic solution apart from catching the error and creating a dummy collection.

The behavior is correct, even manually it reports the same error:

MongoDB Enterprise mongos> use blah;
switched to db blah
MongoDB Enterprise mongos> db.aColl.explain("executionStats").find().finish();
uncaught exception: Error: explain failed: {
        "ok" : 0,
        "errmsg" : "database blah not found",
        "code" : 26,
        "codeName" : "NamespaceNotFound",
        "$clusterTime" : {
                "clusterTime" : Timestamp(1662145776, 1),
                "signature" :

{                         "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),                         "keyId" : NumberLong(0)                 }

        },
        "operationTime" : Timestamp(1662145776, 1)
} :

Note that the above is output from connecting to mongos. If connecting to a mongod the command works just fine without the db existing.

Comment by Vishnu Kaushik [ 11/Aug/22 ]

CC adi.zaimi@mongodb.com for visibility.

Comment by Vishnu Kaushik [ 11/Aug/22 ]

Thanks for the quick fix! Is there a longer term solution we can implement? Because the same thing seems to be happening with explain_distinct.js here

Comment by Vishnu Kaushik [ 25/Jul/22 ]

I think REP-1233 is a similar mongos-on-start problem, though it may not be exactly the same one listed here.

Generated at Thu Feb 08 06:10:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.