sequelize / sequelize-pool

Resource pool implementation. It can be used to throttle expensive resources.
Other
38 stars 17 forks source link

Bug Fix: Do not leak expired resources to pending requests #19

Closed chriskchew closed 4 years ago

chriskchew commented 4 years ago

Well, you asked for more contributions... :)

During scale out testing we noticed that every once in a while a resource was dispensed and then promptly closed. I traced the issue back to a logic bug in my previous PR #18: An expended connection would be placed into the available list, dispensed, then closed in the next tick while it was in use.

This PR fixes that issue by not placing expended resources back on the availables list and instead directly calling _dispense().

I added a unit test for the scenario, and we also confirmed improved behavior when testing a large scenario against AWS Aurora.

Thank you!

papb commented 4 years ago

Great! Thanks!