question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Increased database connections in sequelize 5

See original GitHub issue

We upgraded from Sequelize 4.x to 5.x recently and have noticed that we are seeing many more connections to our database since the upgrade. In the graph below you can see that the number of connections (red line) has gone up dramatically since the upgrade on 13 April while the number of servers (green line) has not changed much at all. I see that pooling changed in v5 but it seems that our config should still be valid and that nothing should have changed the number of connections we’re seeing. Wondering if anyone else is seeing this because it wasn’t an expected behavior.

Screen Shot 2019-05-03 at 10 19 59

What are you doing?

  pool: {
    max: parseInt(config.database.pool.max), //Set to 40
    min: parseInt(config.database.pool.min), //Set to 2
    idle: 2 * 60 * 1000,
    acquire: 15 * 1000
  },

To Reproduce Steps to reproduce the behavior:

  1. Use the same config on sequelize 4.x and 5.x
  2. Generate a bunch of requests and/or async tasks that require the database
  3. Compare the number of open database connections

What do you expect to happen?

I would expect the pool to use roughly the same number of database connections

What is actually happening?

The number of database connections goes up by roughly 2.5x

Environment

Dialect:

  • postgres Dialect library version: 7.10.0 (pg) Database version: 10.6 Sequelize version: 5.6.0 Node Version: 11.12.0 OS: Ubuntu 16.04

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
itai-sagicommented, Jun 6, 2019

We see this happening as-well. something interesting is that when killing a connection via mysql kill command, basically causes sequelize to create 2 more connections. we’re still investigating the causes.

some more information: what I saw is that when killing a connection, 2 errors are thrown here https://github.com/sequelize/sequelize/blob/master/lib/dialects/mysql/connection-manager.js#L95 EPIPE and PROTOCOL_CONNECTION_LOST, so 2 new connections are made for 1 that was dropped, and it is not being reaped

3reactions
sushantdhimancommented, Jun 11, 2019

🎉 This issue has been resolved in version 5.8.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connection Pool - Sequelize
If you're connecting to the database from a single process, you should create only one Sequelize instance. Sequelize will set up a connection...
Read more >
Sequelize report too many connections at some time
Many database libraries and ORM's will try to reuse connections when possible, ... Never have more than five open connections (max: 5).
Read more >
Cross-Database Associations in Sequelize ORM | by David Mart
The first thing you need to do is to manually adjust the Sequelize database connection instance, like so: Then, add the schema name...
Read more >
How To Use Sequelize with Node.js and MySQL - DigitalOcean
In this section, you will connect the Node.js application to the MySQL database using Sequelize. To connect to the database, open server.js for ......
Read more >
The Ultimate Guide To Get Started With Sequelize ORM
To connect to a database, you need to open a connection stream between Sequelize and the running MySQL Daemon. So, create a directory...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found