I believe I have found a bug in QueuePool causing it to leak connections 
during instantiation of _ConnectionFairy objects, when get_connection() 
raises an exception.

A simple way to reproduce this is to have a connection expire and simulate 
a network issue to have get_connection() raise an exception. We increase 
the internal connections counter _overflow in _do_get(), but as the weakref 
handler _finalize_fairy() has not been setup yet, we never decrease 
_overflow back despite the connection never being established in the first 
place.

I have written a simple reproducer (http://pastebin.com/7iKVYWNn) and here 
is its output: http://pastebin.com/F5b7L75K

The solution for us was to add an exception handler for get_connection() to 
ensure that _finalize_fairy() is called - here is the patch: 
http://pastebin.com/uvurWhSV

Looking forward to your comments

Thanks

-- Navid

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to