Reputation: 1025
Is there a way way to get the locks statistics per collection in MongoDB 3.x ? This info is not present into the
db.serverStatus()
Ideally I would retain the collection names as well.
Upvotes: 1
Views: 7492
Reputation: 10497
The db.currentOp() command should give you more insight about locks due to currently running operations.
Here's a sample output of the command:
On query:
{
"locks": {"^myDB": "R"},
"ns": "myDB.bar",
"op": "query",
"opid": 1349152,
"query": {"test": 1},
"secs_running": 15,
"waitingForLock": true
}
On update:
{
"locks": {
"^": "w",
"^local": "W",
"^myDB": "W"
},
"ns": "myDB.bar",
"op": "update",
"opid": 1344808,
"query": {},
"secs_running": 53,
"waitingForLock": false
}
I haven't tested it, but something like this should get the locks for a collection:
db.currentOp(
{
$and: [
{"waitingForLock" : true},
{"ns" : "mydb.mycoll"}
]
}
)
Source: http://blog.mlab.com/2014/02/mongodb-currentop-killop/
Upvotes: 4
Reputation: 8988
Try looking at:
"locks" : {
"Global" : {
"acquireCount" : {
"r" : NumberLong(5776),
"w" : NumberLong(14),
"W" : NumberLong(4)
}
},
"Database" : {
"acquireCount" : {
"r" : NumberLong(2872),
"w" : NumberLong(1),
"R" : NumberLong(7),
"W" : NumberLong(13)
}
},
"Collection" : { <-------------- see collection locks
"acquireCount" : {
"r" : NumberLong(2735)
}
},
For more information visit Collection locks at MongoDB website
Upvotes: 1