diff --git a/app/api/routers/rbac_operator.py b/app/api/routers/rbac_operator.py index c005ebe..8666ffc 100644 --- a/app/api/routers/rbac_operator.py +++ b/app/api/routers/rbac_operator.py @@ -239,13 +239,8 @@ async def sync_compute_users( pats += 1 except Exception: # noqa: BLE001 pass - # 审计为最佳努力:循环里 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 + # 对账幂等自明、且涉及对 db 只读 + 大量外部调用,不写审计(write_audit 的 commit 与该只读会话 + # 事务交互会触发 PendingRollback/UNIQUE 冲突并污染会话)。仅返回统计。 return {"total": len(users), "synced": created, "pat_issued": pats}