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
MySQL is not reconnecting gracefully, causing store to fail with "Cannot enqueue Query after fatal error" #18
Comments
The reason the reconnect method (and other related methods) were removed from Hopefully this weekend I will have some time to look into this in more detail. |
Ok. FYI: Even if the manager re-connects, It appears, the simplest solution is to just use a connection pool and call |
You can use connection pooling by passing the following option when instantiating the session store: {
useConnectionPooling: true
} |
Yeah, that's a fine option! However, you are currently caching the |
Ah yes. You are correct. I will fix this over the weekend. Well actually.. Correct me if I am wrong, but it appears that according to the node-mysql documentation which you just linked to, you can use the var mysql = require('mysql');
var pool = mysql.createPool({
connectionLimit : 10,
host : 'example.org',
user : 'bob',
password : 'secret'
});
pool.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
if (err) throw err;
console.log('The solution is: ', rows[0].solution);
}); |
Hum... Interesting! So, in index.js, renaming |
No. The {
useConnectionPooling: true
} No modification is required to make it work even now. |
Ok... Maybe the naming should be adjusted correspondingly? |
Currently,
express-mysql-session
cannot properly handle DB connection failures. After a connection has been terminated, the store will always fail with:That is actually not a bug but intended behavior. I quote
node-mysql
's official documentation:However, gracefully handling connection failures are still an open issue.
In version 0.0.12,
express-mysql-session
had areconnect()
method. I would suggest to 1) either re-introduce that behavior or 2) provide some other way of handling DB connection problems.For reference, I am sharing the code that handled connection errors in
0.0.12
, based on this suggestion (it works very well, and I will now go back to0.0.12
for that reason):The text was updated successfully, but these errors were encountered: