Increased database connections in sequelize 5
See original GitHub issueWe 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.
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:
- Use the same config on sequelize 4.x and 5.x
- Generate a bunch of requests and/or async tasks that require the database
- 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:
- Created 4 years ago
- Reactions:7
- Comments:14 (6 by maintainers)
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
andPROTOCOL_CONNECTION_LOST
, so 2 new connections are made for 1 that was dropped, and it is not being reaped🎉 This issue has been resolved in version 5.8.9 🎉
The release is available on:
Your semantic-release bot 📦🚀