Skip to content

Instantly share code, notes, and snippets.

@venriq
Last active August 29, 2015 14:27
Show Gist options
  • Save venriq/ab5cba19207277d77cfa to your computer and use it in GitHub Desktop.
Save venriq/ab5cba19207277d77cfa to your computer and use it in GitHub Desktop.
Lists long running operations in MongoDB and terminate the offending one
PRIMARY> db.currentOp().inprog.forEach(
function(op) {
if(op.secs_running > 5) printjson(op);
}
)
//or a simpler version
PRIMARY> db.currentOp({"active": true, "secs_running": {$gt: 5}})
//==============================================
{
"opid" : 17929957,
"active" : true,
"secs_running" : 31,
"microsecs_running" : NumberLong(31040570),
"op" : "remove",
"ns" : "t13_valet_qa.notifications",
"query" : {
"timestamp" : {
"$lt" : ISODate("2015-05-01T00:00:00Z")
}
},
"client" : "168.215.186.226:58710",
"desc" : "conn894403",
"threadId" : "0x7f94bffd9700",
"connectionId" : 894403,
"locks" : {
"^" : "w",
"^local" : "W",
"^t13_valet_qa" : "W"
},
"waitingForLock" : false,
"numYields" : 634,
"lockStats" : {
"timeLockedMicros" : {
"r" : NumberLong(0),
"w" : NumberLong(49078148)
},
"timeAcquiringMicros" : {
"r" : NumberLong(0),
"w" : NumberLong(7527546)
}
}
}
//==========================================
PRIMARY> db.killOp(17929957) //this is the poid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment