grpc-node icon indicating copy to clipboard operation
grpc-node copied to clipboard

Update from 0.6.18 to 0.7.0 introduces a leak

Open apatora opened this issue 6 years ago • 7 comments

Problem description

Today (17/03) a new version of google-gax has been released with an update of the grpc-js package from 0.6 to 0.7 as you can see here https://github.com/googleapis/gax-nodejs/releases. We use this package as a dependency of the NodeJS Bigtable client module. Since then we experienced multiple crashes of our containers (on Kubernetes) due to high resources usage. It turns out that by reverting grpc-js to 0.6.18 the following way in package.json everything comes back to normal :

{
    "resolutions": {
        "@grpc/grpc-js": "0.6.18"
    }
}

and then :

npx npm-force-resolutions
npm i

apatora avatar Mar 17 '20 19:03 apatora

Can you get a memory dump to see what is leaking?

murgatroid99 avatar Mar 17 '20 20:03 murgatroid99

Just FYI, google-gax v1.15.1 is out (pinning @grpc/grpc-js to ^0.6.18).

alexander-fenster avatar Mar 17 '20 20:03 alexander-fenster

Oh great thanks for the rollback.

Do you still need the dump ? I am not sure if it's a memory or a CPU issue yet. I can also activate GRPC_VERBOSITY. Right now is the peak hour so I'll try tomorrow if you need it.

apatora avatar Mar 17 '20 20:03 apatora

@apatora Yes, the dump will be very helpful. We rolled back just as a precaution.

alexander-fenster avatar Mar 17 '20 21:03 alexander-fenster

I managed to reproduce the issue locally with a simple script :

const Bigtable = require('@google-cloud/bigtable')

const bigtable = new Bigtable({
  projectId: '<projectId>',
})

const instance = bigtable.instance('<instance>')

;(async () => {
  let iteration = 0
  while (true) {
    console.log(iteration)
    const promises = []
    for (let i = 0; i < 1000; i++) {
      promises.push(
        instance
          .table('<table>')
          .row('<test>')
          .exists()
      )
    }
    await Promise.all(promises)
    iteration++
  }
})()

With [email protected], it crashes after the ~47th iteration with an out of memory error whereas with [email protected] the memory stabilizes at ~250Mb.

apatora avatar Mar 18 '20 21:03 apatora

I've published version 0.7.2, which appears to correct the leak in my own local testing. Would you mind trying it out?

murgatroid99 avatar Mar 19 '20 21:03 murgatroid99

Tried the 0.7.2 version and it works fine. Thanks!

apatora avatar Mar 23 '20 11:03 apatora