Connection pool deadlock, bug#5736

Folks,

I need some +1's and suggestions for following patch:

https://rails.lighthouseapp.com/projects/8994/tickets/5736-connections-not-released-in-rails-3#ticket-5736-5

Even if original patch is rejected, the attached test is valuable and I would request it to be merged with rails.