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

collStats should return ok:1 and all fields when the namespace does not exist

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1.1
    • Component/s: Storage
    • Labels:
    • Backwards Compatibility:
      Minor Change
    • Sprint:
      Storage NYC 2018-07-02

      Description

      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)
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ben.judd Ben Judd
              Reporter:
              shane.harvey Shane Harvey
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: