]> 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:14:36 +0000 (13:14 -0400)
commita1f220cb4d1a04412a53200f454fbfc706e136b3
tree4b8aa33b1d69acd101b48de7c009182888e5affe
parentf746fd78e303352d426a15c1f76ee835ce399d44
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
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