Skip to content

Instantly share code, notes, and snippets.

View kainlite's full-sized avatar
:shipit:

Gabriel Garrido kainlite

:shipit:
View GitHub Profile
// 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
@kainlite
kainlite / gist:1902333
Created February 24, 2012 17:45
Mongo Assertion Error With MapReduce
class SomeDocument
include MongoMapper::Document
# Other stuff...
def self.tag_cloud_map
<<-MAP
function() {
this.tags.forEach(function(tag) {
emit(tag, 1);