]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Close connection if begin fails
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 13 Dec 2019 17:44:23 +0000 (12:44 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 13 Dec 2019 17:47:32 +0000 (12:47 -0500)
commitbeeb289696099d9284f61944de15c0763d861694
treecf2b7d4a315746b454a9543e31c30dc41aa05ba0
parent798c6f36ffeb87b396a79b5c61c67af7c65bed1d
Close connection if begin fails

Fixed issue where by if the "begin" of a transaction failed at the Core
engine/connection level, such as due to network error or database is locked
for some transactional recipes, within the context of the :class:`.Session`
procuring that connection from the connection pool and then immediately
returning it, the ORM :class:`.Session` would not close the connection
despite this connection not being stored within the state of that
:class:`.Session`.  This would lead to the connection being cleaned out by
the connection pool weakref handler within garbage collection which is an
unpreferred codepath that in some special configurations can emit errors in
standard error.

Fixes: #5034
Change-Id: I6502a55791d86845f34bc10889c218f00765dfdc
(cherry picked from commit ff471152b62f71accda62d9ede87e0107b8a8bcb)
doc/build/changelog/unreleased_13/5034.rst [new file with mode: 0644]
lib/sqlalchemy/orm/session.py
test/orm/test_transaction.py