修复:完善旧数据纳入事务读取

This commit is contained in:
焦龙言
2026-09-23 13:48:49 +08:00
parent 91cf862248
commit b11c457e61
3 changed files with 128 additions and 12 deletions
@@ -97,7 +97,6 @@ class TestBatchAdoptionService:
update_by=user_name,
update_time=now,
)
await db.commit()
impacts = [
BatchImpactModel(
table_name=table_name,
@@ -107,7 +106,7 @@ class TestBatchAdoptionService:
)
for table_name in BATCH_MODELS
]
return TestBatchPreviewModel(
response = TestBatchPreviewModel(
batch_id=batch_id,
batch_name=batch.batch_name,
preview_token=raw_token,
@@ -115,6 +114,8 @@ class TestBatchAdoptionService:
total_count=sum(item.count for item in impacts),
impacts=impacts,
)
await db.commit()
return response
except Exception:
await db.rollback()
raise
@@ -137,9 +138,9 @@ class TestBatchAdoptionService:
cls._assert_token(batch, command.preview_token, datetime.now())
await TestBatchAdoptionDao.lock_roots(db, command.roots)
first_selection = await TestBatchGraph.compute_closure(db, command.roots)
first_selection = await TestBatchGraph.compute_locked_closure(db, command.roots)
await TestBatchAdoptionDao.lock_selection(db, first_selection)
locked_selection = await TestBatchGraph.compute_closure(db, command.roots)
locked_selection = await TestBatchGraph.compute_locked_closure(db, command.roots)
expected_scope_hash = batch.preview_scope_hash
if (
selection_hash(first_selection) != expected_scope_hash