New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.0.0-rc.1 connection pool get exhausted using pool's query method #270
Comments
thanks for report @dolphin278 ! There was a number of changes in |
hi @dolphin278 - any update on this? |
@sidorares I've got narrowed it down – when I've put some clumsy ad-hoc solution for my own use, which is not 100% compatible with your original code (it does not return function (sql, values, cb) {
if (typeof values === 'function') {
cb = values;
values = [];
}
this.getConnection(function (err, conn) {
if (err) return cb(err);
var cmdQuery = Connection.createQuery(sql, values, function () {
conn.release();
if (typeof cb === 'function') return cb.apply(this, arguments);
});
conn._resolveNamedPlaceholders(cmdQuery);
var rawSql = conn.format(cmdQuery.sql, cmdQuery.values || []);
cmdQuery.sql = rawSql;
conn.query(cmdQuery);
});
}; |
oh. Yes, createQuery parameters are incorrect Corresponding code from node-mysql https://github.com/felixge/node-mysql/blob/1720920f7afc660d37430c35c7128b20f77735e3/lib/Pool.js#L184-L212 with few modifications should be possible to do in a similar way Pool.prototype.query = function (sql, values, cb) {
var cmdQuery = Connection.createQuery(sql, values);
this.getConnection(function (err, conn) {
if (err) {
cmd.on('error', function() {});
cmd.onResult(err);
return;
}
conn._resolveNamedPlaceholders(cmdQuery);
var rawSql = conn.format(cmdQuery.sql, cmdQuery.values || []);
cmdQuery.sql = rawSql;
conn.query(cmdQuery).once('end', function() {
conn.release();
})
});
return cmdQuery;
}; would you be able to test this and submit pr? |
@sidorares I am so sorry for the delay, I will get back to this ASAP (hopefully, this weekend) |
Thanks @dolphin278 ! If you happen to work on this please have a look at linked issues as well. I'm afraid I wont have time for next week or two |
@dolphin278 could you recheck with current master? |
I have the same issue, always using the |
@felixfbecker can you check it's "full pool" problem by logging |
Finally, I got back and tried to reproduce original issue on 1.1.1. Can not reproduce it anymore. So issue looks like a resolved one. Got some other weird stuff, like not releasing connection back to pool after executing |
Partly – it my own error – I called promisified function (err, value) {
if (promise === null) return;
if (err) {
var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
promise._attachExtraTrace(wrapped);
promise._reject(wrapped);
} else if (!multiArgs) {
promise._fulfill(value);
} else {
var $_len = arguments.length;var args = new Array(Math.max($_len - 1, 0)); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];};
promise._fulfill(args);
}
promise = null;
} cb: function () {
console.log('pool:execute:cb');
conn.release();
cb.apply(this, arguments);
} But what interesting, calling |
so both |
I am getting this same issue with the
mysql2 version: 1.1.1 ((This is my first comment on github so please accept my apology if I did something wrong or missed something out)) |
I am also still getting this issue. I don't have to time to investigate much, but it only happens when using the methods on the pool directly. I worked around it by first getting a connection with |
I know this is bad bug report, since I am currently not able to provide reproducible test, but anyway:
Pool.query
method, you eat all connections and they are not released to pool (callback is never invoked and connection is not released)Pool.query
works just fine, pool is not getting exhaustedPool.execute
works properly, connections are successfully returning to poolNode v5.6.0. I'll try to prepare working example for debugging, but I am in a bit of a rush here, so I don't know exactly when.
The text was updated successfully, but these errors were encountered: