[SERVER-26949] Waiting connections of current Created: 08/Nov/16  Updated: 01/Feb/18  Resolved: 14/Nov/16

Status: Closed
Project: Core Server
Component/s: Security
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Minor - P4
Reporter: Timur Sultanaev Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

Have I understand correctly that according to https://docs.mongodb.com/v3.2/reference/method/db.currentOp/ and SERVER-5085 there is possibility to gain list of all connections even if they are waiting (no operations processed) BUT only if there is a special grant for user. And if I use "$ownOps" I cannot see such waiting connections.

In another words next table misses one of the value:

  Need grant Do not need grant (only own info)
Just operations with connections db.currentOp() db.currentOp( { "$ownOps": true }

)

Operations with connections and waiting connections db.currentOp(true) or db.currentOp( { "$all": true }

)

Not supported


 Comments   
Comment by Timur Sultanaev [ 21/Nov/16 ]

Hi Spencer Jackson, what you've said

you are able to stack $all and $ownOps together, to display all of the operations and idle connections which have been executed or opened by your currently logged in user

sounds very good and obviously is true, I've just checked it.

I didn't tried it at first because current documentation
https://docs.mongodb.com/v3.2/reference/method/db.currentOp/
specifically mention that

If the document includes "$all": true along with Output Fields conditions, only the "$all":true applies.

Now I see that it means "only the "$all":true and, optionally, $ownOps applies."

Thanks!

Comment by Spencer Jackson [ 14/Nov/16 ]

Hi strowk, you are correct that when using $ownOps, you are unable to see the connections and operations of any user other than yourself.

However, you are able to stack $all and $ownOps together, to display all of the operations and idle connections which have been executed or opened by your currently logged in user:

db.currentOp({"$all": true, "$ownOps": true})

For example, if I open two shells to my local mongod, authenticate with a user which only has the readWrite@local role in both shells, and run the above command, I get the following output:

MongoDB Enterprise > db.currentOp({"$ownOps": true, "$all": true})
{
        "inprog" : [
                {
                        "desc" : "conn9",
                        "threadId" : "139960811624192",
                        "connectionId" : 9,
                        "client" : "127.0.0.1:36344",
                        "appName" : "MongoDB Shell",
                        "active" : false
                },
                {
                        "desc" : "conn8",
                        "threadId" : "139960826275584",
                        "connectionId" : 8,
                        "client" : "127.0.0.1:36342",
                        "appName" : "MongoDB Shell",
                        "active" : true,
                        "opid" : 3618,
                        "secs_running" : 0,
                        "microsecs_running" : NumberLong(160),
                        "op" : "command",
                        "ns" : "admin.$cmd",
                        "query" : {
                                "currentOp" : 1,
                                "$ownOps" : true,
                                "$all" : true
                        },
                        "numYields" : 0,
                        "locks" : {
 
                        },
                        "waitingForLock" : false,
                        "lockStats" : {
 
                        }
                }
        ],
        "ok" : 1
}

The idle authenticated connection is displayed in the output.

I will close this ticket as Works as Designed. If you disagree, or have further issues with this feature, please feel free to reopen!

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