{"action":"opened","issue":{"url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/219","repository_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo","labels_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/219/comments","events_url":"https://api.github.com/repos/lightblue-platform/lightblue-mongo/issues/219/events","html_url":"https://github.com/lightblue-platform/lightblue-mongo/issues/219","id":136744357,"number":219,"title":"Support limiting time query can run","user":{"login":"jewzaam","id":480388,"avatar_url":"https://avatars.githubusercontent.com/u/480388?v=3","gravatar_id":"","url":"https://api.github.com/users/jewzaam","html_url":"https://github.com/jewzaam","followers_url":"https://api.github.com/users/jewzaam/followers","following_url":"https://api.github.com/users/jewzaam/following{/other_user}","gists_url":"https://api.github.com/users/jewzaam/gists{/gist_id}","starred_url":"https://api.github.com/users/jewzaam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jewzaam/subscriptions","organizations_url":"https://api.github.com/users/jewzaam/orgs","repos_url":"https://api.github.com/users/jewzaam/repos","events_url":"https://api.github.com/users/jewzaam/events{/privacy}","received_events_url":"https://api.github.com/users/jewzaam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-26T16:26:29Z","updated_at":"2016-02-26T16:26:29Z","closed_at":null,"body":"We've hit some cases where very long running queries impact lightblue either by taking db resources (maybe?) or crud resources (such as connections).\r\n\r\nThere are two options to mitigate this I'm seeing.\r\n1) global config to force all queries to use indexes, [notablescan](https://docs.mongodb.org/v2.6/reference/parameters/#param.notablescan)\r\n2) per-request limit max time a query can execute with [maxTimeMS](https://docs.mongodb.org/v2.6/reference/method/cursor.maxTimeMS/)\r\n\r\nWould like to discuss (hopefully briefly) what other options exist and which one(s) should be adopted. \r\n\r\nI think the notablescan option is going to be a problem in that we cannot control what clients request from lightblue.  And it doesn't guarentee a long running query that does use an index won't be executed.\r\n\r\nI think we should use maxTimeMS even if we set the timeout to something longer than other components in the architecture will timeout.  For example, if I query lightblue and a proxy times out after 30 seconds, the query will continue to run on the mongo server!  At least for find operations, this is a waste of resources.  We can debate if only find should be killed, but I think we should start there given it's the biggest problem we see so far.\r\n\r\nMy proposal, therefore, is:\r\n* add support for already existing execution option: timeLimit\r\n* add global default for timeLimit used if execution option is not specified\r\n* in mongo controller use timeLimit as maxTimeMS\r\n\r\nLooks like with the timeLimit in core we had this in mind.  It just didn't get implemented fully.\r\n\r\n@BVulaj @bserdar @dcrissman @paterczm @snehagunta thoughts?"}}