Skip to content

Commit

Permalink
Do not add bad connections back to pool
Browse files Browse the repository at this point in the history
See knex#452.

This is a hacky workaround proof-of-concept conversation starter that
fixes the issue, but should be done in a cross-dialect way, and it
should also include tests.
  • Loading branch information
Elliot Foster committed Nov 24, 2014
1 parent f66efd8 commit 262c58d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/pool.js
Expand Up @@ -60,6 +60,13 @@ Pool.prototype.acquire = function(callback, priority) {

// Release a connection back to the connection pool.
Pool.prototype.release = function(connection, callback) {
// avoid re-adding failed connections to the connection pool
if (connection && connection.__knex__disposed) {
return setTimeout(function() {
callback();
},1);
}

if (this.genericPool) {
this.genericPool.release(connection, callback);
} else {
Expand Down

0 comments on commit 262c58d

Please sign in to comment.