Options are available on the client side (maxTimeMS starting from version 2.6).
There is no attractive global option on the server side, since it will affect all databases and all operations, even those that the system must be working for a long time for internal work (for example, tail for oplog for replication). In addition, it may be good that some of your requests will take a long time to complete by design.
The correct way to resolve this issue is to track the currently running requests with a script and kill those that work for a long time, and initiate the user / client - you can create exceptions for requests that take a long time to execute by design, or have different threshold values ββfor different queries / collections, etc.
Then you can use the db.currentOp () method (in the shell) to view all current operations. The secs_running field indicates how long the operation has been running. Be careful not to kill any lengthy operations that are not triggered by your application / client - this may be a necessary system operation, for example, moving pieces in a fragmentation cluster (as only one example).
source share