sidorares / sidorares/node-mysql2

Pooled connections memory leaks upgrading past 3.9.4

Open
#3,202 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs reproduction
Dominant language
TypeScript
Stars
4.4k
Forks
680
Avg merge
9h 7m
Merged PRs (30d)
59

Description

Using pooled connections, we upgraded from 3.9.4 to 3.11.3 and instantly saw huge memory leaks in many deployed production enviroments. See screenshots below from google cloud run where the line with the i and dotted lines marks the deployment of the libary 3.11.3. Its very clear that its the changes between 3.9.4 and 3.11.3

Screenshot of container insights in production after deployement
383277311-f3291061-cb36-4996-a0bd-8fdf803be781

I downgraded to 3.9.7 and still have the memory leaks.

Rolling back to mysql 3.9.4 solves the issue

We are using typeorm but the mysql config parms are just passed down. I will write the relevant ones below;

{
          type: xxxx,
          username: xxxx,
          password: xxxx,
          database: xxxx,
          entities: dmsDbEntities,
          synchronize: false,
          pool: {
            max: 25,
            min: 0,
          },
          extra = {
            socketPath: /xxxx/x 
          }
        }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start by reproducing the reported upgrade from 3.9.4 with pooled connections, the shown max/min pool settings, and socketPath configuration, then compare behavior through 3.11.3 and 3.9.7. Done means the memory leak is isolated and a regression test or focused reproduction demonstrates the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, node.js, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.