Search code examples
mongodbtimeout

MongoDB : Kill all tasks in mongoDB that takes too long and exceeds certain wait-time


I want to kill all the queries that are taking too long to execute. I have tried socketTimeOut but it is not the good way to do the same and the expected result is not achieved.

Read this for explanation http://mongodb.github.io/node-mongodb-native/2.2/reference/faq/. There is also an option of maxTimeMS, but we cannot make it general and pass it in mongoClient URI options. It is query specific. Is there any other parameter that I can set for the terminating all the queries that take more time to execute.

Any settings in mongo config can also help, but it should work for all the types of queries like insert,find,update, remove. I have also seen db.currentOp() option, but I want to know if it can be done in a better way and if db.currentOp() is the only option, how can I use it to find and terminate a query with Java Driver.

Thank you


Solution

  • I have gone through all the documentations, there is no way we can implement it. The thing is maxTimeMS is implemented for each query but not on the Global URI level.