Closed vgaltes closed 6 years ago
Should I call pool.end() at the end of my program?
I believe that calling pool.end() at the end should solve this
Yes, thanks!
EDIT: I've moved the below issue to #90
I've got a similar problem, in that my connection hangs only every now and again. I'm exporting my pool and using it in a bunch of routes, so calling pool.end() closes the pool before any of the routes can use it.
In the mysql error log I get:
[Note] Aborted connection 3018 to db: myDb' user: 'myUsr' host: 'localhost' (Got an error reading communication packets)
My pool is exported like this:
const mysql = require("promise-mysql");
const pool = mysql.createPool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
connectionLimit: 10
});
module.exports = pool;
There are very few mysql connections on the server, and the issue is rare - one in every several dozen database queries hangs and logs the above error.
I'm on Ubuntu 16.04, and typing mysql --version
prints:
mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper
And all my databases are InnoDB. I'm struggling to see what I've got wrong. Is there anything in the above that stands out?
Hi,
I'm sure I'm doing something wrong but when I execute this simple code using a pool it hangs (if I use a connection it finishes correctly).
What am I doing wrong?
Thanks,