Skip to content

Instantly share code, notes, and snippets.

@sean-lin
Created August 16, 2016 03:54
Show Gist options
  • Save sean-lin/e21bfcadab8af5cea7f7ee17f12abd38 to your computer and use it in GitHub Desktop.
Save sean-lin/e21bfcadab8af5cea7f7ee17f12abd38 to your computer and use it in GitHub Desktop.
a script to kill query ops starting with a namespace from mongo database
killLongRunningOps = function(startswith) {
currOp = db.currentOp();
currOp.inprog.forEach(function(op) {
if (op.op == "query" && op.ns.startsWith(startswith)) {
print("Killing opId: " + op.opid + " running over for secs: " + op.secs_running);
db.killOp(op.opid);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment