]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
contextmanager skips rollback if trans says to skip it
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 2 Dec 2021 00:27:25 +0000 (19:27 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 Dec 2021 18:05:44 +0000 (13:05 -0500)
commita845da8b0fc5bb172e278c399a1de9a2e49d62af
treeca86fe60e4e69fdef15cb9593d57d9042678700f
parent55e0497b080bf7f5159faa5abcb341269ebfdc7f
contextmanager skips rollback if trans says to skip it

Fixed issue where if an exception occurred when the :class:`_orm.Session`
were to close the connection within the :meth:`_orm.Session.commit` method,
when using a context manager for :meth:`_orm.Session.begin` , it would
attempt a rollback which would not be possible as the :class:`_orm.Session`
was in between where the transaction is committed and the connection is
then to be returned to the pool, raising the exception "this
sessiontransaction is in the committed state". This exception can occur
mostly in an asyncio context where CancelledError can be raised.

Fixes: #7388
Change-Id: I1a85a3a7eae79f3553ddf1e3d245a0d90b0a2f40
doc/build/changelog/unreleased_14/7388.rst [new file with mode: 0644]
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/util.py
lib/sqlalchemy/orm/session.py
test/engine/test_transaction.py
test/orm/test_transaction.py