[SERVER-31183] currentOp output can contain an "ns" field with a value like "dbName.$cmd" Created: 20/Sep/17  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Diagnostics, Querying
Affects Version/s: 3.2.16, 3.4.9, 3.5.13
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: David Storch Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: QFB, query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Query Execution
Operating System: ALL
Participants:
Case:

 Description   

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.



 Comments   
Comment by Asya Kamsky [ 30/May/18 ]

If we ever expect to allow a single (bulk) update command to specify multiple updates going to different collections in a database  (As discusses in SERVER-2172 and SERVER-20211)  then that's a case where command collection may not have an appropriate single value.

 

 

Generated at Thu Feb 08 04:26:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.