I was recently getting some strange behavior running my integration tests whereby I was getting out-of-connection pool errors. These appear as timeouts in the system/deadlocks. After spending hours hunting down the problem I discovered two places where I was not properly releasing the connection (and thus I was connection leaking). In general this is not easy to detect (and I even added some logic to my connection manager class to track new and released connections (and to try and flag if they get out of wack)
I came across a strange situation with promises that I didn't think would happen, but it must be a timing related issue.
I had some code like the following:
var defer = q.defer(); connection.query(query_string, function (err, rows) { if( err ) { defer.reject(err); // rejection will rollback and release in caller } // do another operation on connection and return to caller defer.resolve(somedata); }); return defer.promise;
No comments:
Post a Comment