irmorteza
irmorteza

Reputation: 1654

How to kill a long queries from C# Driver - mongodb

I wrote a c# program that works with MongoDB.

It finds long time running queries but I can not kill them. I googled so much but I didn't find anything useful.

Can anyone help me with killing the queries?

Upvotes: 1

Views: 666

Answers (1)

Guillaume
Guillaume

Reputation: 13138

You must use killOp to stop the query

With your driver you may try something like this

var db = server.GetDatabase("test", WriteConcern.Acknowledged);
var currentOp = db.GetCurrentOp();
var opid = ... fetch from currentOp result
db.RunCommand(new CommandDocument("killOp", opid));

Upvotes: 1

Related Questions