Merge "db: Avoid relying on autobegin"

This commit is contained in:
Zuul 2023-07-17 14:37:39 +00:00 committed by Gerrit Code Review
commit a0559af692
1 changed files with 8 additions and 5 deletions

View File

@ -4259,8 +4259,10 @@ def _get_fk_stmts(metadata, conn, table, column, records):
# Create the shadow table for the referencing table.
fk_shadow_tablename = _SHADOW_TABLE_PREFIX + fk_table.name
try:
fk_shadow_table = schema.Table(
fk_shadow_tablename, metadata, autoload_with=conn)
with conn.begin():
fk_shadow_table = schema.Table(
fk_shadow_tablename, metadata, autoload_with=conn,
)
except sqla_exc.NoSuchTableError:
# No corresponding shadow table; skip it.
continue
@ -4368,9 +4370,10 @@ def _archive_deleted_rows_for_table(
rows_archived = 0
deleted_instance_uuids = []
try:
shadow_table = schema.Table(
shadow_tablename, metadata, autoload_with=conn,
)
with conn.begin():
shadow_table = schema.Table(
shadow_tablename, metadata, autoload_with=conn,
)
except sqla_exc.NoSuchTableError:
# No corresponding shadow table; skip it.
conn.close()