]> 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:26 +0000 (13:17 -0400)
commitca69db7e1ff6dabbbd57b1bca3387d0321da19a5
tree5f07083dbb33af2243777982dedc77adf592d084
parent42ec1f70138d51dd7e61578453faa0f4d47f6ec3
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)
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