I have a code that analyze a lot of data received by websocket and from some time found that MySQL DB (JawsDB on Heroku) return error message:'User 'xxxxx' has exceeded the 'max_user_connections' resource (current value: 10)'.
I understand that it is MySQL limit, what I am do not understand - why is my code creates NEW connection on each query (while pool options defined).
How I figured it out: placed breakpoint on ${proj}/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:
class ConnectionManager extends AbstractConnectionManager {
....
async connect(config) {
// HERE IS PUT BREAKPOINT WHICH HIT FOR EACH QUERY
const connectionConfig = {
....
};
try {
const connection = await new Promise((resolve, reject) => {
const connection = this.lib.createConnection(connectionConfig);
....
} catch (err) {
switch (err.code) {
default:
// '{"code":"ER_USER_LIMIT_REACHED","errno":1226,"sqlState":"42000","sqlMessage":"User 'xxx' has exceeded the 'max_user_connections' resource (current value: 10)"}'
throw new SequelizeErrors.ConnectionError(err);
}
}
}
}
Here is how Sequelize instance created (once, I checked it):
const sequelize = new Sequelize(config.databaseUri, {
dialect: 'mysql',
dialectOptions: { decimalNumbers: true },
pool: {
max: 5,
min: 1,
idle: 10000
}
});