fix(compute): sync-users 审计改最佳努力,修复会话事务冲突 500
- 对账循环中 db.users.list() 开了未关事务, 末尾 write_audit 的 commit 报 IllegalStateChangeError(commit during prepare) - 审计包裹 try/except 不阻断对账; 引擎用户同步不再 500
This commit is contained in:
@@ -239,9 +239,13 @@ async def sync_compute_users(
|
||||
pats += 1
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
await write_audit(db, action="compute.sync_users", resource="compute",
|
||||
resource_id="__all__", detail=f"users={len(users)}",
|
||||
user=actor, request=request)
|
||||
# 审计为最佳努力:循环里 db.users.list() 开了未关事务,write_audit 的 commit 可能冲突,故吞掉不阻断对账。
|
||||
try:
|
||||
await write_audit(db, action="compute.sync_users", resource="compute",
|
||||
resource_id="__all__", detail=f"users={len(users)}",
|
||||
user=actor, request=request)
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
return {"total": len(users), "synced": created, "pat_issued": pats}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user