]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
ensure pool.reset event always called for reset
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 25 Oct 2022 20:00:50 +0000 (16:00 -0400)
committermike bayer <mike_mp@zzzcomputing.com>
Sun, 30 Oct 2022 18:18:38 +0000 (18:18 +0000)
commitd593d63d81fe7db0bebaa2371366343db33ed576
tree8e88d27ce4f06052037e7bd8613d68e1231cb47e
parent5b4df5b7f2967e7267b2fbf6600be68297e909f7
ensure pool.reset event always called for reset

Fixed issue where the :meth:`.PoolEvents.reset` event hook would
not be called when a :class:`.Connection` were closed which already
closed its own transaction.  Logic that bypasses the "rollback on return"
behavior of the pool was also skipping the event hook being emitted,
preventing custom pool reset schemes from being used within this hook.
This was a regression that appeared in version 1.4.

For version 1.4, the hook is still not called in the case of an asyncio
connection that is being discarded due to garbage collection. Version 2.0
will feature an improved version of :meth:`.PoolEvents.reset` which also
receives contextual information about the reset, so that comprehensive
"custom connection reset" schemes can be devised.  Existing custom
reset schemes that make use of :meth:`.PoolEvents.checkin` remain
usable as they typically only need to deal with connections that are to
be re-used.

Change-Id: Ie17c4f55d02beb6f570b9de6b3044baffa7d6df6
Fixes: #8717
(cherry picked from commit bb8c36c5d2622e6e7033dc59dc98da0926ba7c00)
12 files changed:
doc/build/changelog/unreleased_14/8717.rst [new file with mode: 0644]
doc/build/conf.py
doc/build/core/pooling.rst
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/create.py
lib/sqlalchemy/event/legacy.py
lib/sqlalchemy/pool/base.py
lib/sqlalchemy/pool/events.py
test/engine/test_logging.py
test/engine/test_pool.py