The "collStats" command on non-existent namespace should be consistent with other commands on non-existent namespaces, and return success (ok:1) and similar to dbStats command should return a document similar in format to that for existing collection but with 0's for sizes.
This will also make the $collStats aggregation stage behave consistently whether only latencyStats or storageStats are requested: currently latencyStats returns a document on non-existent namespace, but storageStats generates an error. There are no other aggregation stages that generate an error on a non-existent collection that I could find.
Original description:
collStats does not return an error code when the database or collection does not exist:
> db.runCommand({collStats: "not-present"}) { "ns" : "test.not-present", "ok" : 0, "errmsg" : "Collection [test.not-present] not found.", "operationTime" : Timestamp(1497566635, 1) } > db.getSiblingDB("not-present").runCommand({collStats: "not-present"}) { "ns" : "not-present.not-present", "ok" : 0, "errmsg" : "Database [not-present] not found.", "operationTime" : Timestamp(1497566645, 1) }
It should also return an error code, NamespaceNotFound would be a good choice:
> db.runCommand({collStats: "not-present"}) { "ns" : "test.not-present", "ok" : 0, "errmsg" : "Collection [test.not-present] not found.", "code" : 26, "codeName" : "NamespaceNotFound", "operationTime" : Timestamp(1497566635, 1) } > db.getSiblingDB("not-present").runCommand({collStats: "not-present"}) { "ns" : "not-present.not-present", "ok" : 0, "errmsg" : "Database [not-present] not found.", "code" : 26, "codeName" : "NamespaceNotFound", "operationTime" : Timestamp(1497566645, 1) }
- is duplicated by
-
SERVER-51206 collStats command does not return an error when the collection does not exist on sharded clusters
- Closed
- is related to
-
SERVER-51206 collStats command does not return an error when the collection does not exist on sharded clusters
- Closed
- related to
-
SERVER-36210 Last stable Mongos not abiding by new .stats() behavior for nonexistent namespace
- Closed