]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
catch all BaseException in pool and revert failed checkouts
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 12 Dec 2022 18:47:27 +0000 (13:47 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 13 Dec 2022 14:48:00 +0000 (09:48 -0500)
commit225eff40f28e943c80dbe8cd2fcd7322e1bdb816
treeaa81099ad1017bfd8699d4b837dbf4b63ceb2e45
parent2f279ce32235a69b9db6a0048230db9c34ff70db
catch all BaseException in pool and revert failed checkouts

Fixed a long-standing race condition in the connection pool which could
occur under eventlet/gevent monkeypatching schemes in conjunction with the
use of eventlet/gevent ``Timeout`` conditions, where a connection pool
checkout that's interrupted due to the timeout would fail to clean up the
failed state, causing the underlying connection record and sometimes the
database connection itself to "leak", leaving the pool in an invalid state
with unreachable entries. This issue was first identified and fixed in
SQLAlchemy 1.2 for :ticket:`4225`, however the failure modes detected in
that fix failed to accommodate for ``BaseException``, rather than
``Exception``, which prevented eventlet/gevent ``Timeout`` from being
caught. In addition, a block within initial pool connect has also been
identified and hardened with a ``BaseException`` -> "clean failed connect"
block to accommodate for the same condition in this location.
Big thanks to Github user @niklaus for their tenacious efforts in
identifying and describing this intricate issue.

Fixes: #8974
Change-Id: I95a0e1f080d0cee6f1a66977432a586fdf87f686
(cherry picked from commit a71917204dcf12a93d957a0fa29c9df97d0411ee)
doc/build/changelog/unreleased_14/8974.rst [new file with mode: 0644]
lib/sqlalchemy/pool/base.py
test/engine/test_pool.py