I'm trying to figure out if there's a way to apply a query timeout in the script file
of MongoDB to prevent slow/idle/hanging requests.
I am referring https://docs.mongodb.com/manual/reference/method/cursor.maxTimeMS/#examples documentation.
Now I am trying to write script as below for the maxTimeMS
as below:-
#!/bin/bash
db.collection.find({ $query: {}, $maxTimeMS: 100 })
And it is giving an error:-
mongodb-timeout.sh: line 4: syntax error near unexpected token `{'
mongodb-timeout.sh: line 4: `db.collection.find({ $query: {}, $maxTimeMS: 100 })'
Does anybody have an idea? Thanks in advance
I think maxTimeMS is the curser option, not a system-wide variable. As you can see in their jira you might be able to write some script to achieve this.