Fix compatibility with oslo.db 12.1.0

oslo.db 12.1.0 has changed the default value for the 'autocommit'
parameter of 'LegacyEngineFacade' from 'True' to 'False'. This is a
necessary step to ensure compatibility with SQLAlchemy 2.0. However, we
are currently relying on the autocommit behavior and need changes to
explicitly manage sessions. Until that happens, we need to override the
default.

Change-Id: I04b336a42b5cbb458badde3bb04d35363d7834d8
This commit is contained in:
Hongbin Lu 2022-09-17 06:58:03 +00:00
parent f847ff85c4
commit 9d92de5423
1 changed files with 3 additions and 0 deletions

View File

@ -45,6 +45,9 @@ _FACADE = None
def _create_facade_lazily():
global _FACADE
if _FACADE is None:
# FIXME(hongbin): we need to remove reliance on autocommit semantics
# ASAP since it's not compatible with SQLAlchemy 2.0
db_session.enginefacade.configure(__autocommit=True)
_FACADE = db_session.enginefacade.get_legacy_facade()
if profiler_sqlalchemy:
if CONF.profiler.enabled and CONF.profiler.trace_sqlalchemy: