Repository navigation
Closed
Labels
Description
Hi ,
i am using mysql2 with bluebird on nodejs 8.
as
const mysql = require('mysql2/promise');
const Promise = require("bluebird");
config.Promise = Promise;//plus database connection configuration
pool = mysql.createPool(config);
function GetSqlConnection() {
return pool.getConnection().disposer(function(connection) {
connection.release();
});
};after sometime i get hit by this warning,
i get , 11 end listeners added. 11 drain listeners added etc ...
at _addListener (events.js:281:19)
at PoolConnection.addListener (events.js:298:10)
at /home/test/servers/v6/project/node_modules/mysql2/promise.js:8:14
at Array.forEach (native)
at inheritEvents (/home/test/servers/v6/project/node_modules/mysql2/promise.js:7:6)
at new PromiseConnection (/home/test/servers/v6/project/node_modules/mysql2/promise.js:37:3)
at /home/test/servers/v6/project/node_modules/mysql2/promise.js:228:17
at /home/test/servers/v6/project/node_modules/mysql2/lib/pool.js:36:14
at _combinedTickCallback (internal/process/next_tick.js:95:7)
at process._tickCallback (internal/process/next_tick.js:161:9)
---------------------------------------------
at process.emitWarning (internal/process/warning.js:154:18)
at _addListener (events.js:289:17)
at PoolConnection.addListener (events.js:298:10)
at /home/test/servers/v6/project/node_modules/mysql2/promise.js:8:14
at Array.forEach (native)
at inheritEvents (/home/test/servers/v6/project/node_modules/mysql2/promise.js:7:6)
at new PromiseConnection (/home/test/servers/v6/project/node_modules/mysql2/promise.js:37:3)
at /home/test/servers/v6/project/node_modules/mysql2/promise.js:228:17
at /home/test/servers/v6/project/node_modules/mysql2/lib/pool.js:36:14
at _combinedTickCallback (internal/process/next_tick.js:95:7)
at process._tickCallback (internal/process/next_tick.js:161:9)
---------------------------------------------
at Pool.getConnection (/home/test/servers/v6/project/node_modules/mysql2/lib/pool.js:35:20)
at /home/test/servers/v6/project/node_modules/mysql2/promise.js:224:14
at Promise._execute (/home/test/servers/v6/project/node_modules/bluebird/js/release/debuggability.js:300:9)
at Promise._resolveFromExecutor (/home/test/servers/v6/project/node_modules/bluebird/js/release/promise.js:483:18)
at new Promise (/home/test/servers/v6/project/node_modules/bluebird/js/release/promise.js:79:10)
at PromisePool.getConnection (/home/test/servers/v6/project/node_modules/mysql2/promise.js:223:10)
at Db.GetSqlConnection (/home/test/servers/v6/project/db.js:34:23)
at Db.verify (/home/test/servers/v6/project/db.js:254:31)Reacted by Maik Marschner, Oskar Larsson Högfeldt and Alexander Kupchenko
Activity
sidorares commentedon Jun 2, 2017
thanks for report @aankur
might be side effect of #567 @Myhlamaeus can you have a look?
sidorares commentedon Jun 2, 2017
@aankur could you reduce your case to something completely self contained?
aankur commentedon Jun 2, 2017
db access file
hijaq commentedon Jun 2, 2017
Can confirm having the same error and it happens only when using bluebird's
usingwithdisposermethod to release connections andmysql21.3.0+ package. The small code to reproduce:result:
sidorares commentedon Jun 3, 2017
thanks @aankur @hijaq will try to investigate
thexeos commentedon Jun 3, 2017
I've opened the issue for this in different mysql project mysqljs/mysql#1742 by accident.
I got the traces with --trace-warnings flag for Node v7.10.0:
I am not using bluebird however.
aankur commentedon Jun 3, 2017
i am able to reproduce it without bluebird disposer
Fix for sidorares#577, Remove listening to events after releasing the…
thexeos commentedon Jun 3, 2017
The remaining question is: how should the pool behave when it is actively using 10+ connections. For example, when multiple queries are running in parallel to aggregate data or alter table. The event listeners should be present until the query is done executing.
Maybe some kind of a super-callback function that will only be attached once and then route and process events centrally. I can see situations when 50 or more connections will be managed by the pool at the same time, and they can all be in an active state at once. That would also mean 50 * 4 = 200 event listeners on one object.
sidorares commentedon Jun 7, 2017
@thexeos EventEmitter warning is issued when you attach more then 10 listeners per event to one target. Pool attaches event per connection: conn1.on('connect') => pool.emit('connect') conn2.on('connect') => pool.emit('connect') etc
rlidwka commentedon Jun 9, 2017
I have the similar issue here, and that's how I reproduce it:
Just create a pool, and repeatedly connect/release. After 10th connection a couple of warnings will appear:
Note that those 5 warnings are for different events:
error,end,drain,connectandenqueuerespectively.Using
node v8.1.0,mysql2 v1.3.3.sidorares commentedon Jun 9, 2017
@rlidwka #578 should fix this but I was going to have a look and maybe refactor original implementation - just creating pool should not set up any additional listeners, only when you do
pool.on('.... Also currently events fire from non-promise pool and pass unwrapped pool / poolconnection as parameterthexeos commentedon Jun 10, 2017
@sidorares There are no
pool.on('...in my code. My situation is very similar to @rlidwka's example:It works until it receives 10+ messages simultaneously. Then it prints the warnings.
bhstrifork commentedon Jun 23, 2017
Any news on this? I just ran into this myself using version 1.3.5
sidorares commentedon Jun 23, 2017
@bhstrifork sorry didn't have time yet. #578 should fix this but I really wanted to refactor original cause and that fix would no longer be relevant
odino commentedon Jul 16, 2017
Same issue right here -- any idea for a fix?
redo event delegation in promise wrappers to be lazy, self-cleaning
karthick4in commentedon May 4, 2018
go to this link. you issue related to this one.
mysqljs/mysql#979
kodekameleon commentedon Sep 19, 2018
I'm still seeing this issue in 1.6.1