I can't believe I have to ask this, but how do I stop a query I just ran, which is now running, and will obviously take a very long time to complete in the Mongo shell? Control+C
appears to crash the shell, and spits out a ton of errors. The silly solutions suggested in this post of course do not do anything. I understand that I could like open up another terminal tab and
run db.currentOp()
, find the operation ID, and then run db.killOp()
, but I can't believe that's the only solution. I must be missing something obvious.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Based on Alex's answer.
Query current running operations:
db.currentOp()
Kill the operation based on opid
db.killOp(30318806)
回答2:
According to Mongo documentation, you should:
- Obtain the current operation ID via
db.currentOp()
- Kill opp via
db.killOp()
Good example script can be found here.
回答3:
For sharded cluster:
db.currentOp()
db.killOp("shard_id:opid")
For example:
db.killOp("shard0000:3134616")