]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
dont erase transaction if rollback/commit failed outside of asyncpg
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Sep 2024 14:37:29 +0000 (10:37 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 2 Sep 2024 17:17:33 +0000 (13:17 -0400)
commit5a9882a56ead5152cacdebfee9b7789879b9ec05
tree53ec0cc01cf453cf51bf79ffe981cb6640f969e0
parent3b5f0fcfbe5fe6bca5566d4a37b28cfe2bd89f8d
dont erase transaction if rollback/commit failed outside of asyncpg

Fixed critical issue in the asyncpg driver where a rollback or commit that
fails specifically for the ``MissingGreenlet`` condition or any other error
that is not raised by asyncpg itself would discard the asyncpg transaction
in any case, even though the transaction were still idle, leaving to a
server side condition with an idle transaction that then goes back into the
connection pool.   The flags for "transaction closed" are now not reset for
errors that are raised outside of asyncpg itself.  When asyncpg itself
raises an error for ``.commit()`` or ``.rollback()``, asyncpg does then
discard of this transaction.

Fixes: #11819
Change-Id: I12f0532788b03ea63fb47a7af21e07c37effb070
(cherry picked from commit a1f220cb4d1a04412a53200f454fbfc706e136b3)
(cherry picked from commit ca69db7e1ff6dabbbd57b1bca3387d0321da19a5)
doc/build/changelog/unreleased_14/11819.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/asyncpg.py
test/dialect/postgresql/test_async_pg_py3k.py