Created
January 27, 2025 08:48
-
-
Save fazlurr/03382cacf5ac68b55c197db533de2b83 to your computer and use it in GitHub Desktop.
Revisions
-
fazlurr created this gist
Jan 27, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ var killLongRunningOps = function (table = 'submission', maxSecsRunning = 5000, kill = false) { var ns = 'orderonline_db.' + table; if (table === '*') { ns = /^orderonline_db\./; } var currOp = db.currentOp({"active" : true,"secs_running" : { "$gt" : maxSecsRunning },"ns" : ns}); var operations = currOp.inprog; for (var i = 0; i < operations.length; i++) { var operation = operations[i]; print(i + ". Operation: " + operation.opid); print("- NS: " + operation.ns); print("- OP: " + operation.op); print("- Secs Running: " + operation.secs_running); if (kill) { print("- Killing operation: " + operation.opid); try { db.killOp(operation.opid); } catch (error) { console.log('- Error Killing: ', error); } } print("--------------------"); } } killLongRunningOps('*', 1000, false)