Rollback the session after performing stats schema validation (#89904)

This commit is contained in:
J. Nick Koston 2023-03-20 06:15:11 -10:00 committed by GitHub
parent 51b12cbf96
commit 6bb80adbb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2504,7 +2504,9 @@ def _validate_db_schema_utf8(
# Try inserting some metadata which needs utfmb4 support # Try inserting some metadata which needs utfmb4 support
try: try:
with session_scope(session=session_maker()) as session: # Mark the session as read_only to ensure that the test data is not committed
# to the database and we always rollback when the scope is exited
with session_scope(session=session_maker(), read_only=True) as session:
old_metadata_dict = statistics_meta_manager.get_many( old_metadata_dict = statistics_meta_manager.get_many(
session, statistic_ids={statistic_id} session, statistic_ids={statistic_id}
) )
@ -2605,7 +2607,9 @@ def _validate_db_schema(
StatisticsShortTerm, StatisticsShortTerm,
) )
try: try:
with session_scope(session=session_maker()) as session: # Mark the session as read_only to ensure that the test data is not committed
# to the database and we always rollback when the scope is exited
with session_scope(session=session_maker(), read_only=True) as session:
for table in tables: for table in tables:
_import_statistics_with_session( _import_statistics_with_session(
instance, session, metadata, (statistics,), table instance, session, metadata, (statistics,), table