|
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.
|