{"action":"created","issue":{"url":"https://api.github.com/repos/graphile/postgraphile/issues/543","repository_url":"https://api.github.com/repos/graphile/postgraphile","labels_url":"https://api.github.com/repos/graphile/postgraphile/issues/543/labels{/name}","comments_url":"https://api.github.com/repos/graphile/postgraphile/issues/543/comments","events_url":"https://api.github.com/repos/graphile/postgraphile/issues/543/events","html_url":"https://github.com/graphile/postgraphile/issues/543","id":248207747,"node_id":"MDU6SXNzdWUyNDgyMDc3NDc=","number":543,"title":"totalCount query kills Node.js server with \"heap out of memory\" error","user":{"login":"maxdesiatov","id":112310,"node_id":"MDQ6VXNlcjExMjMxMA==","avatar_url":"https://avatars3.githubusercontent.com/u/112310?v=4","gravatar_id":"","url":"https://api.github.com/users/maxdesiatov","html_url":"https://github.com/maxdesiatov","followers_url":"https://api.github.com/users/maxdesiatov/followers","following_url":"https://api.github.com/users/maxdesiatov/following{/other_user}","gists_url":"https://api.github.com/users/maxdesiatov/gists{/gist_id}","starred_url":"https://api.github.com/users/maxdesiatov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxdesiatov/subscriptions","organizations_url":"https://api.github.com/users/maxdesiatov/orgs","repos_url":"https://api.github.com/users/maxdesiatov/repos","events_url":"https://api.github.com/users/maxdesiatov/events{/privacy}","received_events_url":"https://api.github.com/users/maxdesiatov/received_events","type":"User","site_admin":false},"labels":[{"id":643316587,"node_id":"MDU6TGFiZWw2NDMzMTY1ODc=","url":"https://api.github.com/repos/graphile/postgraphile/labels/Fix%20in%20v4","name":"Fix in v4","color":"006b75","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/graphile/postgraphile/milestones/3","html_url":"https://github.com/graphile/postgraphile/milestone/3","labels_url":"https://api.github.com/repos/graphile/postgraphile/milestones/3/labels","id":3573290,"node_id":"MDk6TWlsZXN0b25lMzU3MzI5MA==","number":3,"title":"4.0","description":"","creator":{"login":"benjie","id":129910,"node_id":"MDQ6VXNlcjEyOTkxMA==","avatar_url":"https://avatars2.githubusercontent.com/u/129910?v=4","gravatar_id":"","url":"https://api.github.com/users/benjie","html_url":"https://github.com/benjie","followers_url":"https://api.github.com/users/benjie/followers","following_url":"https://api.github.com/users/benjie/following{/other_user}","gists_url":"https://api.github.com/users/benjie/gists{/gist_id}","starred_url":"https://api.github.com/users/benjie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjie/subscriptions","organizations_url":"https://api.github.com/users/benjie/orgs","repos_url":"https://api.github.com/users/benjie/repos","events_url":"https://api.github.com/users/benjie/events{/privacy}","received_events_url":"https://api.github.com/users/benjie/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":54,"state":"open","created_at":"2018-08-15T15:40:26Z","updated_at":"2018-08-16T14:55:44Z","due_on":null,"closed_at":null},"comments":8,"created_at":"2017-08-05T20:34:02Z","updated_at":"2018-08-31T10:18:48Z","closed_at":"2017-08-08T17:04:38Z","author_association":"CONTRIBUTOR","body":"Hi, thanks a lot for this wonderful library. I was evaluating it for my project, but stumbled upon an interesting issue. A simple query such as:\r\n\r\n```graphql\r\nquery {\r\n  allDocuments {\r\n    totalCount\r\n  }\r\n}\r\n```\r\n\r\nkills both standalone `postgraphql` CLI and my Node.js server, which uses it as a library. When I run the process with `DEBUG='postgraphql:postgres'` I get this log output:\r\n\r\n```\r\npostgraphql:postgres begin +0ms\r\n  postgraphql:postgres with __local_0__ as ( select __local_1__ as value from \"public\".\"document\" as __local_1__ where \"id\" is not null and true and true and true order by \"id\" using < limit all ) select to_json(__local_0__.value) as value from __local_0__; +8ms\r\n\r\n<--- Last few GCs --->\r\n\r\n[23425:0x103801600]    37186 ms: Mark-sweep 1394.2 (1646.6) -> 1394.2 (1646.6) MB, 42.2 / 0.0 ms  allocation failure GC in old space requested\r\n[23425:0x103801600]    37258 ms: Mark-sweep 1394.2 (1646.6) -> 1394.2 (1615.6) MB, 71.6 / 0.0 ms  last resort \r\n[23425:0x103801600]    37309 ms: Mark-sweep 1394.2 (1615.6) -> 1394.2 (1614.6) MB, 50.7 / 0.0 ms  last resort \r\n\r\n\r\n<--- JS stacktrace --->\r\n\r\n==== JS stack trace =========================================\r\n\r\nSecurity context: 0x46d37c9bbd9 <JS Object>\r\n    1: stringSlice(aka stringSlice) [buffer.js:556] [pc=0x11e69fdc6588](this=0x46d37c82241 <undefined>,buf=0x1cb4cb208be9 <an Uint8Array with map 0x3f132bc3e849>,encoding=0x2a9d4b207419 <String[4]: utf8>,start=6,end=3523696)\r\n    2: _readValue [/Volumes/Data/node_bin/node_modules/pg/lib/connection.js:~546] [pc=0x11e69fd87b04](this=0x3584be8a9209 <a Connection with map 0x144d4ebc88d1>,buffer=0x1cb...\r\n\r\nFATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory\r\n 1: node::Abort() [/usr/local/bin/node]\r\n 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]\r\n 3: v8::Utils::ReportOOMFailure(char const*, bool) [/usr/local/bin/node]\r\n 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]\r\n 5: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/bin/node]\r\n 6: v8::internal::Factory::NewStringFromUtf8(v8::internal::Vector<char const>, v8::internal::PretenureFlag) [/usr/local/bin/node]\r\n 7: v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [/usr/local/bin/node]\r\n 8: node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding, v8::Local<v8::Value>*) [/usr/local/bin/node]\r\n 9: void node::Buffer::(anonymous namespace)::StringSlice<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&) [/usr/local/bin/node]\r\n10: v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/local/bin/node]\r\n11: v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/usr/local/bin/node]\r\n12: v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/bin/node]\r\n13: 0x11e69f3040bd\r\n```\r\n\r\nIt looks like `totalCount` queries don't get converted to `SELECT COUNT(*) FROM document;`. Are there any workarounds available for this and any plans to fix this?\r\n\r\nThanks again."},"comment":{"url":"https://api.github.com/repos/graphile/postgraphile/issues/comments/417620978","html_url":"https://github.com/graphile/postgraphile/issues/543#issuecomment-417620978","issue_url":"https://api.github.com/repos/graphile/postgraphile/issues/543","id":417620978,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNzYyMDk3OA==","user":{"login":"benjie","id":129910,"node_id":"MDQ6VXNlcjEyOTkxMA==","avatar_url":"https://avatars2.githubusercontent.com/u/129910?v=4","gravatar_id":"","url":"https://api.github.com/users/benjie","html_url":"https://github.com/benjie","followers_url":"https://api.github.com/users/benjie/followers","following_url":"https://api.github.com/users/benjie/following{/other_user}","gists_url":"https://api.github.com/users/benjie/gists{/gist_id}","starred_url":"https://api.github.com/users/benjie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjie/subscriptions","organizations_url":"https://api.github.com/users/benjie/orgs","repos_url":"https://api.github.com/users/benjie/repos","events_url":"https://api.github.com/users/benjie/events{/privacy}","received_events_url":"https://api.github.com/users/benjie/received_events","type":"User","site_admin":false},"created_at":"2018-08-31T10:18:48Z","updated_at":"2018-08-31T10:18:48Z","author_association":"MEMBER","body":"I think Devin deleted the post; not sure why. I've not seen any memory exhaustion errors in the v4 RCs."}}
{"actor":{"display_login":"benjie"}}