]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
fix race conditions in lambda statements
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 7 Jun 2022 19:00:20 +0000 (15:00 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 8 Jun 2022 20:59:12 +0000 (16:59 -0400)
commit53ae884a0c5d107d1a4d9b4b64192c3b3c507ca8
treecffa1e86e3df30f6f645101b9ceb01a66fca2808
parent7eba007385a75aa0f29a1466cfbb335aa6abbe8b
fix race conditions in lambda statements

Fixed multiple observed race conditions related to :func:`.lambda_stmt`,
including an initial "dogpile" issue when a new Python code object is
initially analyzed among multiple simultaneous threads which created both a
performance issue as well as some internal corruption of state.
Additionally repaired observed race condition which could occur when
"cloning" an expression construct that is also in the process of being
compiled or otherwise accessed in a different thread due to memoized
attributes altering the ``__dict__`` while iterated, for Python versions
prior to 3.10; in particular the lambda SQL construct is sensitive to this
as it holds onto a single statement object persistently. The iteration has
been refined to use ``dict.copy()`` with or without an additional iteration
instead.

Fixes: #8098
Change-Id: I4e0b627bfa187f1780dc68ec81b94db1c78f846a
(cherry picked from commit 117878f7870377f143917a22160320a891eb0211)
doc/build/changelog/unreleased_14/8098.rst [new file with mode: 0644]
lib/sqlalchemy/sql/base.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/lambdas.py