Viewing and Terminating Current Operation

View Current Operation(s) in Progress

> db.currentOp();
> // same as: db.$cmd.sys.inprog.findOne()
{ inprog: [ { "opid" : 18 , "op" : "query" , "ns" : "mydb.votes" ,
              "query" : "{ score : 1.0 }" , "inLock" : 1 }
          ]
}

Fields:

  • opid - an incrementing operation number.  Use with killOp().
  • op - the operation type (query, update, etc.)
  • ns - namespace for the operation (database + collection name)
  • query - the query spec, if operation is a query

NOTE: currentOp's output format varies from version 1.0 and version 1.1 of MongoDB.  The format above is for 1.1 and higher.

You can also do

db.$cmd.sys.inprog.find()

or this version which prints all connections

db.$cmd.sys.inprog.find( { $all : 1 } )

Terminate (Kill) an Operation in Progress

// <= v1.2
> db.killOp()
> // same as: db.$cmd.sys.killop.findOne()
{"info" : "no op in progress/not locked"}

// v>= 1.3
> db.killOp(1234/*opid*/)
> // same as: db.$cmd.sys.killop.findOne({op:1234})

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

IF YOU HAVE A QUESTION, POST IT TO THE USER GROUP.

These pages are fine for comments, but for questions, your best bet will always be the MongoDB User Group.

blog comments powered by Disqus