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

collStats does not return error code when asked to operate on a non-existent collection in an existing database

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.6.18
    • Component/s: None
    • None
    • Query Optimization
    • ALL

      This affects 3.6 and potentially earlier servers.

      Database exists, collection does not:

      MongoDB Enterprise mongos> db.runCommand({collStats:'foo'})
      {
      	"sharded" : false,
      	"primary" : "shard01",
      	"ns" : "mongoid_test.foo",
      	"ok" : 0,
      	"errmsg" : "Collection [mongoid_test.foo] not found.",
      	"operationTime" : Timestamp(1596397090, 1),
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1596397090, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

      Neither database nor collection exist:

      MongoDB Enterprise mongos> db.runCommand({collStats:'foo'})
      {
      	"ok" : 0,
      	"errmsg" : "database bar not found",
      	"code" : 26,
      	"codeName" : "NamespaceNotFound",
      	"operationTime" : Timestamp(1596397102, 1),
      	"$clusterTime" : {
      		"clusterTime" : Timestamp(1596397102, 1),
      		"signature" : {
      			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
      			"keyId" : NumberLong(0)
      		}
      	}
      }
      

      Note that the second command had an error code (26) and the first command did not have an error code.

      4.0 uses error code 8 here as far as I can tell.

            Assignee:
            peter.volk@mongodb.com Peter Volk
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: