question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pool: connection ending in fatal error are not removed from the generic pool

See original GitHub issue

when having a fatal error on a mysql connection using knex 0.6.22 & pool & mysql driver, the connection is not removed from the pool.

Further requests using this connection end in mysql driver error “cannot enqueue … after fatal error” (PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR)

a workaround :

var knex;

var connectionErrorHandler = function (connection, err) {
  if (connection && err && err.fatal) {
    if (connection.removedFromThePool)
      return;
    connection.removedFromThePool = true;
    knex.client.pool.genericPool.destroy(connection);
  }
};

var config =  {
  client: 'mysql',
  (...)
  pool: {
    (...)
    afterCreate: function (connection, callback) {
      connection.on('error', connectionErrorHandler.bind(null, connection));
      connection.on('end', connectionErrorHandler.bind(null, connection));
      callback();
    }
  }
};

knex = knexInit(config);

it might be linked to #206

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
elhigucommented, Nov 16, 2017

@shwuhk I would recommend to not use 0.14 until 0.14.1 is released. There are couple of nasty issues which were missed when generic-pool was updated. I’m working on those and hope to get 0.14.1 out this week.

0reactions
elhigucommented, Nov 20, 2017

@shwuhk 0.14.1 it is out

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tomcat, JOTM and MYSQL - Generic Pool Cleanup
I am experiencing problems with Tomcat 5 and MySQL and JOTM. When I run tomcat using the org.objectweb.jndi.
Read more >
WebSphere Application Server StaleConnectionExceptions
Set the datasource Purge Policy to entire pool. This option determines if you will mark only the offending connection as stale, should a...
Read more >
Reproduce MySQL error: The server closed the connection ...
The solution is use pooling connection ! You can wrote code to handle connection manually, it works. However pooling ...
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
Read more >
8.4 Connector/ODBC Errors and Resolutions (FAQ)
This problem can occur when you upgrade an existing Connector/ODBC installation, rather than removing and then installing the updated version. Warning. To fix ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found