axelspringer / graphql-google-pubsub

A graphql-subscriptions PubSub Engine using Google PubSub
MIT License
136 stars 43 forks source link

Possible memory leak, Application crashing #18

Open NathofGod opened 5 years ago

NathofGod commented 5 years ago

We're getting memory issues when leaving our API running. We have a number of subscriptions and we have subscriptions for IoT devices.

Our server is GraphQL running on Koa inside Kubernetes (GKE) with node:10.13.0-alpine and pubsub v- 0.30.3

<--- Last few GCs --->

[77204:0x10280c000] 3801963 ms: Mark-sweep 1332.8 (1450.8) -> 1323.8 (1454.8) MB, 4806.6 / 2.5 ms (average mu = 0.120, current mu = 0.053) allocation failure scavenge might not succeed [77204:0x10280c000] 3808588 ms: Mark-sweep 1337.0 (1454.8) -> 1328.0 (1457.3) MB, 6342.0 / 2.4 ms (average mu = 0.077, current mu = 0.043) allocation failure scavenge might not succeed

<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0x2284524dbe3d] 1: StubFrame [pc: 0x228452810481] Security context: 0x0b6e4061e6e9 2: makeBidiStreamRequest [0xb6e138f7c01] [/Users/nathanthomas/Documents/Code/Smart Spaces/graph/node_modules/@axelspringer/graphql-google-pubsub/node_modules/grpc/src/client.js:753] [bytecode=0xb6e94b7ee59 offset=90](this=0x0b6e65e21561 ,path=0x0b6e66c2cfe9 <String[42]: /google.pubs...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0x10003cf99 node::Abort() [/usr/local/bin/node] 2: 0x10003d1a3 node::OnFatalError(char const, char const) [/usr/local/bin/node] 3: 0x1001b7835 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, bool) [/usr/local/bin/node] 4: 0x100585682 v8::internal::Heap::FatalProcessOutOfMemory(char const) [/usr/local/bin/node] 5: 0x100588155 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node] 6: 0x100583fff v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node] 7: 0x1005821d4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node] 8: 0x10058ea6c v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node] 9: 0x10058eaef v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node] 10: 0x100573f62 v8::internal::Handlev8::internal::TransitionArray v8::internal::Factory::NewWeakFixedArrayWithMapv8::internal::TransitionArray(v8::internal::Heap::RootListIndex, int, v8::internal::PretenureFlag) [/usr/local/bin/node] 11: 0x10056626a v8::internal::Factory::NewTransitionArray(int, int) [/usr/local/bin/node] 12: 0x10087cd3d v8::internal::TransitionsAccessor::Insert(v8::internal::Handlev8::internal::Name, v8::internal::Handlev8::internal::Map, v8::internal::SimpleTransitionFlag) [/usr/local/bin/node] 13: 0x1006aaa78 v8::internal::Map::ConnectTransition(v8::internal::Handlev8::internal::Map, v8::internal::Handlev8::internal::Map, v8::internal::Handlev8::internal::Name, v8::internal::SimpleTransitionFlag) [/usr/local/bin/node] 14: 0x1006999d1 v8::internal::Map::CopyReplaceDescriptors(v8::internal::Handlev8::internal::Map, v8::internal::Handlev8::internal::DescriptorArray, v8::internal::Handlev8::internal::LayoutDescriptor, v8::internal::TransitionFlag, v8::internal::MaybeHandlev8::internal::Name, char const, v8::internal::SimpleTransitionFlag) [/usr/local/bin/node] 15: 0x1006960cf v8::internal::Map::CopyAddDescriptor(v8::internal::Handlev8::internal::Map, v8::internal::Descriptor*, v8::internal::TransitionFlag) [/usr/local/bin/node] 16: 0x100695e32 v8::internal::Map::CopyWithField(v8::internal::Handlev8::internal::Map, v8::internal::Handlev8::internal::Name, v8::internal::Handlev8::internal::FieldType, v8::internal::PropertyAttributes, v8::internal::PropertyConstness, v8::internal::Representation, v8::internal::TransitionFlag) [/usr/local/bin/node]

jonas-app commented 5 years ago

Thx for the detailed report. We struggle with a memory leak since the beginning. See https://github.com/axelspringer/graphql-google-pubsub/issues/16 for some more information. Currently I have no time to investigate and fix this issue. I'm very glad for any helpful input and in the best case fixing PRs.