-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Leaked exception if database crashes. (MySQL server has gone away) #2442
Comments
if you have pool min size 0 does it still happen? Does it happen if you are not making any queries, but just initialise the kenx instance? |
@elhigu It still happend when I set pool min size 0. It happen when I am not making any queries after period of time. |
@conglq what period of time are we talking to? 1 minute, 1 hour, 1 day? |
So are you able to reproduce the problem with following code (I need exact steps to reproduce the problem, I cannot spend hours just guessing the way to make it fail)? const knex = require('knex')({
client: 'mariasql',
connection: {
host: config.host,
user: config.user,
password: config.password,
db: config.database,
charset: 'utf8',
pool: { min: 0, max: 10 },
acquireConnectionTimeout: 30000
}
});
async function main() {
await knex.raw('select 1');
await periodOfTime();
await knex.raw('select 1');
}
main(); |
Just a wild guess, but could this be due to not specifying |
@wubzz I thought the default pool setting |
@elhigu I run your test script and my app, it crashes after ~15 mins later. |
@conglq please share the code, app that I posted was incomplete |
my code const config = require('../config').mySQL;
const knex = require('knex')({
client: 'mariasql',
connection: {
host: config.host,
user: config.user,
password: config.password,
db: config.database,
charset: 'utf8',
pool: { min: 0, max: 10 },
acquireConnectionTimeout: 30000
}
});
console.log(new Date());
const Bluebird = require('bluebird');
function periodOfTime () {
return Bluebird.delay(1000 * 60 * 60 * 24);
}
async function main () {
await knex.raw('select 1');
await periodOfTime();
await knex.raw('select 1');
}
main(); |
Ok so app actually just crashes during waiting... Is the error message still the same that in OP? |
@elhigu yes, the error message still 'MySQL server has gone away' |
btw. you knex configuration is wrong... IIRC, pool and acquireConnectionTImeout should be in the same level with connection attribute, not nested. connection attributes are the ones passed to bd driver. I'm running the testcase now though. |
@elhigu I'm sorry ! my misstake. But it still makes the same error :(
|
With myslq I still wasn't able to reproduce this. Start DB server:
Create DB:
Running test code:
However I was able to get the error / crash when I closed DB server during waiting. So basically the problem is that knex leaks exception and crashes in that case. I believe that better would be to catch the error and pass to knex in some knex.on('error', ...) event / through query rejection if DB is not available. |
Hello! I have the same problem and I can help with testing/debugging. |
I just noticed that it still has this line: connection.removeAllListeners('error'); in the |
I fixed that too in the PR |
@koskimas thanks! your fix did work 👍 |
Environment
Knex version:0.14.2
Database + version: mariaDb v10.2
OS: Ubuntu
Node: v9.3.0
My connection:
After period of time my node app crash with error:
Please help me resolve this issue. Thanks all!
The text was updated successfully, but these errors were encountered: