{"action":"created","issue":{"url":"https://api.github.com/repos/arangodb/arangodb/issues/1823","repository_url":"https://api.github.com/repos/arangodb/arangodb","labels_url":"https://api.github.com/repos/arangodb/arangodb/issues/1823/labels{/name}","comments_url":"https://api.github.com/repos/arangodb/arangodb/issues/1823/comments","events_url":"https://api.github.com/repos/arangodb/arangodb/issues/1823/events","html_url":"https://github.com/arangodb/arangodb/issues/1823","id":154844682,"number":1823,"title":"Arango crashed hard executing very simple query on windows","user":{"login":"ctmakro","id":9973364,"avatar_url":"https://avatars.githubusercontent.com/u/9973364?v=3","gravatar_id":"","url":"https://api.github.com/users/ctmakro","html_url":"https://github.com/ctmakro","followers_url":"https://api.github.com/users/ctmakro/followers","following_url":"https://api.github.com/users/ctmakro/following{/other_user}","gists_url":"https://api.github.com/users/ctmakro/gists{/gist_id}","starred_url":"https://api.github.com/users/ctmakro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ctmakro/subscriptions","organizations_url":"https://api.github.com/users/ctmakro/orgs","repos_url":"https://api.github.com/users/ctmakro/repos","events_url":"https://api.github.com/users/ctmakro/events{/privacy}","received_events_url":"https://api.github.com/users/ctmakro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-05-14T09:48:23Z","updated_at":"2016-05-14T11:45:28Z","closed_at":null,"body":"Below are the AQL used.\r\n````\r\n//for f in forums\r\n//let f = document(forums,'default')\r\n\r\n    let count_posts = (\r\n      for t in threads\r\n      filter t.fid == f._key\r\n      collect aggregate total = sum(t.count)\r\n      return total\r\n    )[0]\r\n\r\n    let count_threads = (\r\n      for t in threads\r\n      filter t.fid == f._key\r\n      collect with count into total\r\n      return total\r\n    )[0]\r\n\r\n    let count_posts_today = (\r\n      for t in threads\r\n      filter t.fid == f._key && t.tlm > date_now()-86400*1000\r\n      collect aggregate total = sum(t.count_today)\r\n      return total\r\n    )[0]\r\n\r\n    update f with {count_posts,count_posts_today,count_threads} in forums\r\n````\r\nby using `let f = document(forums,'default')` everything's okay;\r\nby using `for f in forums` (forums is a collection with only 3 documents) the ArangoDB service wil immediately crash(100% chance), leaving me an ECONNRESET.\r\n\r\nNodeJS 4.x / Win7 64-bit\r\nSame problem in both 2.8.3 and 2.8.7\r\nSame problem using both arangojs driver, and AQL editor\r\n\r\nThis is very annoying since I'm meeting deadlines for [some company project](https://github.com/lovetheory/nkc2) ."},"comment":{"url":"https://api.github.com/repos/arangodb/arangodb/issues/comments/219215909","html_url":"https://github.com/arangodb/arangodb/issues/1823#issuecomment-219215909","issue_url":"https://api.github.com/repos/arangodb/arangodb/issues/1823","id":219215909,"user":{"login":"fceller","id":392005,"avatar_url":"https://avatars.githubusercontent.com/u/392005?v=3","gravatar_id":"","url":"https://api.github.com/users/fceller","html_url":"https://github.com/fceller","followers_url":"https://api.github.com/users/fceller/followers","following_url":"https://api.github.com/users/fceller/following{/other_user}","gists_url":"https://api.github.com/users/fceller/gists{/gist_id}","starred_url":"https://api.github.com/users/fceller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fceller/subscriptions","organizations_url":"https://api.github.com/users/fceller/orgs","repos_url":"https://api.github.com/users/fceller/repos","events_url":"https://api.github.com/users/fceller/events{/privacy}","received_events_url":"https://api.github.com/users/fceller/received_events","type":"User","site_admin":false},"created_at":"2016-05-14T11:45:28Z","updated_at":"2016-05-14T11:45:28Z","body":"@ctmakro there is a bug in the query engine, which causes this crash. However, if I understand the intent correctly, the query should be rewritten as follows:\r\n\r\n```\r\nfor f in forums\r\n    let posts = (\r\n      for t in threads\r\n      filter t.fid == f._key\r\n      return t.count\r\n    )\r\n    \r\n    let count_posts = sum(posts)\r\n    let count_threads = length(posts)\r\n\r\n    let count_posts_today = sum(\r\n      for t in threads\r\n      filter t.fid == f._key && t.tlm > date_now()-86400*1000\r\n      return t.count_today\r\n    )\r\n\r\n    update f with {count_posts,count_posts_today,count_threads} in forums\r\n```\r\n\r\nThe \"collect into\" should not be necessary, because you want to count given the number of matching documents or sum up the matching threads."}}