[SERVER-20463] Error Code for database not found has changed for listIndexes Created: 17/Sep/15  Updated: 07/Oct/15  Resolved: 22/Sep/15

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.1.7
Fix Version/s: 3.1.9

Type: Bug Priority: Major - P3
Reporter: Craig Wilson Assignee: Kaloian Manassiev
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to PHPLIB-107 DropCollection should not throw excep... Closed
related to PHPLIB-123 ListIndexes should not throw exceptio... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Sprint: Sharding A (10/09/15)
Participants:

 Description   

When running the listIndexes command on a database that does not exist, the error code has changed in a sharded system. Not only that, the error code is different between a mongos and a mongod. Drivers are relying on this error code to provide an empty list to a user rather than an exception as is specified.

3.0.5

mongos> db.runCommand({listIndexes: "foo"})
{ "ok" : 0, "errmsg" : "no database", "code" : 26 }

Latest

2015-09-17T12:40:46.583-0500 I CONTROL  [initandlisten] db version v3.1.8-pre-
2015-09-17T12:40:46.583-0500 I CONTROL  [initandlisten] git version: 4dc43cd451f58d59d63e1516f9b0c52f3bb1dd9d

mongos> db.runCommand({listIndexes: "foo"})
{ "ok" : 0, "errmsg" : "database test not found", "code" : 60 }

> db.runCommand({listIndexes: "foo"})
{ "ok" : 0, "errmsg" : "no database", "code" : 26 }



 Comments   
Comment by Kaloian Manassiev [ 22/Sep/15 ]

As part of this change we have gotten rid of error code 60 (DatabaseNotFound) and now we always return error code 26 (NamespaceNotFound) instead.

I couldn't find any parts of the documentation, which reference 60 specifically, so there might not be need for documentation changes, but I selected 'Driver Changes' as Maybe in order to bring attention.

Comment by Githook User [ 22/Sep/15 ]

Author:

{u'username': u'kaloianm', u'name': u'Kaloian Manassiev', u'email': u'kaloian.manassiev@mongodb.com'}

Message: SERVER-20463 DatabaseNotFound -> NamespaceNotFound

This change replaces all usages of error code 60 (DatabaseNotFound) with
error code 26 (NamespaceNotFound) and obsoletes code 60. From this point
on, error code 26 should be used for all cases where a collection or
database is not found.
Branch: master
https://github.com/mongodb/mongo/commit/c3dc26b52adfc45f86730e862404bce024beeb04

Comment by Kaloian Manassiev [ 18/Sep/15 ]

craiggwilson/behackett - error code 60 is DatabaseNotFound and error code 26 is NamespaceNotFound. In 3.2 we fixed a sharding bug, which was always implicitly creating databases (even on reads) so now we actually get a more specific error. I understand this breaks backwards compatibility though.

In order to simplify the decision of "what do I return if I can't find the database or collection", we are proposing that we get rid of the DatabaseNotFound (code 60) altogether and always just use NamespaceNotFound. This would also take care of this bug.

The only externally visible manifestations for this change would be the explain of the findAndModify command, which will start returning code 26 if the database does not exist.

Comment by Bernie Hackett [ 17/Sep/15 ]

Well, 60 is also defined there, so there's that...

Comment by Bernie Hackett [ 17/Sep/15 ]

Indeed. NamespaceNotFound is defined here: https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err. The server should be using the error codes defined there.

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