CodeFoodPixels / node-promise-mysql

A wrapper for mysqljs/mysql that wraps function calls with Bluebird promises.
MIT License
338 stars 63 forks source link

Occasional aborted connection #90

Closed bdmason closed 6 years ago

bdmason commented 6 years ago

I've got a similar problem to 86 in that my connection hangs every now and again. I'm exporting my pool and using it in a bunch of routes, so calling pool.end() like 86 did to solve their issue closes the pool before any of the routes can use it.

Every now and again 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 explains why my DB connection is occasionally aborted?

CodeFoodPixels commented 6 years ago

This doesn't look like it's an issue with this library. It'll either be an issue with your mysql server instance or with the mysqljs that promise-mysql wraps.

On Thu, 24 May 2018, 08:12 bdmason, notifications@github.com wrote:

I've got a similar problem to 86 https://github.com/lukeb-uk/node-promise-mysql/issues/86 in that my connection hangs every now and again. I'm exporting my pool and using it in a bunch of routes, so calling pool.end() like 86 did to solve their issue closes the pool before any of the routes can use it.

Every now and again 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 explains why my DB connection is occasionally aborted?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lukeb-uk/node-promise-mysql/issues/90, or mute the thread https://github.com/notifications/unsubscribe-auth/AEjy1MRmgL7gVXrSNmvmM0brain16ZREks5t1l1ZgaJpZM4ULrtp .

bdmason commented 6 years ago

Ok I'll close this. It's very odd and if it was a code/package error I'd expect others to have it too.