// kills long running ops in MongoDB (taking seconds as an arg to define "long")
// attempts to be a bit safer than killing all by excluding replication related operations
// and only targeting queries as opposed to commands etc.
killLongRunningOps = function(maxSecsRunning) {
currOp = db.currentOp();
for (oper in currOp.inprog) {
op = currOp.inprog[oper-0];
if (op.secs_running > maxSecsRunning && op.op == "query" && !op.ns.startsWith("local")) {
print("Killing opId: " + op.opid
+ " running over for secs: "
+ op.secs_running);
db.killOp(op.opid);
}
}
};
killLongRunningOps(阈值时间,如1);
来自:http://dba.stackexchange.com/questions/60029/how-do-i-safely-kill-long-running-operations-in-mongodb
类别:技术文章 | 阅读:295138 | 评论:0 |
标签:mongodb