pool: connection ending in fatal error are not removed from the generic pool
See original GitHub issuewhen 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:
- Created 9 years ago
- Comments:10 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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.
@shwuhk 0.14.1 it is out