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

currentOp output can contain an "ns" field with a value like "dbName.$cmd"

    • Query Execution
    • ALL

      The high-level command handling code always sets the namespace associated with an operation to the name of the database concatenated with the string "$cmd":

      https://github.com/mongodb/mongo/blob/44a2de49607e5340efc7e84d265216723d403add/src/mongo/db/service_entry_point_mongod.cpp#L788-L795

      Commands which target a collection, in particular the various CRUD commands, will later overwrite this value to contain a fully qualified namespace such as myDb.myColl. However, if db.currentOp() is executed at the right time, the user might see a string such as myDb.$cmd:

      ...
            "msg": "waiting for write concern",
            "op": "command",
            "numYields": 0,
            "waitingForLock": false,
            "ns": "myColl.$cmd",
      ...
      

      This is a holdover from the legacy OP_QUERY-based commands protocol, in which a command over the myDb database would be issued with the namespace string myDb.$cmd. It is also counter-intuitive to users, who expect this field to always contain the fully-qualified namespace over which their application logically issued the operation. Instead of $cmd, the user should always see the actual collection name.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: