]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add new "sync once" mode for pool.connect
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 21 Apr 2021 18:44:45 +0000 (14:44 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 22 Apr 2021 02:31:42 +0000 (22:31 -0400)
commit37414a752b0036334d0f31ac8cd3aff749c3898b
treee36b3980321484362c4b679caa70ddc464324f43
parented3f2c617239668d74ad3d86aeda0ca2030a5933
Add new "sync once" mode for pool.connect

Fixed critical regression caused by the change in :ticket`5497` where the
connection pool "init" phase no longer occurred within mutexed isolation,
allowing other threads to proceed with the dialect uninitialized, which
could then impact the compilation of SQL statements.

This issue is essentially the same regression which was fixed many years
ago in :ticket:`2964` in dd32540dabbee0678530fb1b0868d1eb41572dca,
which was missed this time as the test suite fo
that issue only tested the pool in isolation, and assumed the
"first_connect" event would be used by the Engine.  However
:ticket:`5497` stopped using "first_connect" and no test detected
the lack of mutexing, that has been resolved here through
the addition of more tests.

This fix also identifies what is probably a bug in earlier versions
of SQLAlchemy where the "first_connect" handler would be cancelled
if the initializer failed; this is evidenced by
test_explode_in_initializer which was doing a reconnect due to
c.rollback() yet wasn't hanging.  We now solve this issue by
preventing the manufactured Connection from ever reconnecting
inside the first_connect handler.

Also remove the "_sqla_unwrap" test attribute; this is almost
not used anymore however we can use a more targeted
wrapper supplied by the testing.engines.proxying_engine
function.

See if we can also open up Oracle for "ad hoc engines" tests
now that we have better connection management logic.

Fixes: #6337
Change-Id: I4a3476625c4606f1a304dbc940d500325e8adc1a
13 files changed:
doc/build/changelog/unreleased_14/6337.rst [new file with mode: 0644]
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/create.py
lib/sqlalchemy/event/attr.py
lib/sqlalchemy/pool/base.py
lib/sqlalchemy/testing/engines.py
test/aaa_profiling/test_pool.py
test/engine/test_execute.py
test/engine/test_pool.py
test/engine/test_reconnect.py
test/engine/test_transaction.py
test/profiles.txt
test/requirements.py