sdepold/sequelize — pull request #134 by megshark (2012-03-13 21:57:12+00:00)
Title: Fix for mysql connection leak (issue #95)

Hi Sascha,

So, I ran into this issue & I happened to have a decent reproducible case. It appears to me that the node-mysql's end() method, which sends a COM_QUIT signal to the socket, was not fully reliable in destroying the connection. I added a little additional logic in the connection manager to help ensure that we weren't spawning & orphaning connections, but the real fix turned out to be calling the client.destroy() method in the client.end() method callback, which makes VERY sure that the connection is actually closed.

I also have some additional test I added previously & some additional sql log events bundled with this -- I did that a while ago but didn't seem worthy of a pull request. I didn't try to add an automated test for the connection leak issue, but the repro case I had with my product basically consisted of hammering the database with concurrent select & update statements. I did run the test suite successfully after making this change & verified the bug fix manually.

I will be working on re-introducing pooling as an option if that sounds OK. Something like a config option to use pooling & optionally set minPoolSize & maxPoolSize. Let me know what you think.

Thanks!
-Meg