diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-21 14:44:45 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-21 22:31:42 -0400 |
| commit | 37414a752b0036334d0f31ac8cd3aff749c3898b (patch) | |
| tree | e36b3980321484362c4b679caa70ddc464324f43 /lib/sqlalchemy/engine/base.py | |
| parent | ed3f2c617239668d74ad3d86aeda0ca2030a5933 (diff) | |
| download | sqlalchemy-37414a752b0036334d0f31ac8cd3aff749c3898b.tar.gz | |
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
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 20d11e578..e0ebb4a98 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -69,6 +69,7 @@ class Connection(Connectable): _execution_options=None, _dispatch=None, _has_events=None, + _allow_revalidate=True, ): """Construct a new Connection.""" self.engine = engine @@ -96,7 +97,7 @@ class Connection(Connectable): self.__in_begin = False self.should_close_with_result = close_with_result - self.__can_reconnect = True + self.__can_reconnect = _allow_revalidate self._echo = self.engine._should_log_info() if _has_events is None: |
