fix(06.2): WR-08 delete_document defers commit so audit log writes in same transaction

This commit is contained in:
curo1305
2026-06-01 14:30:31 +02:00
parent 50b6e7fd06
commit 2072c3ddcd
2 changed files with 17 additions and 4 deletions
+4 -2
View File
@@ -658,11 +658,13 @@ async def delete_document(
},
)
ok = await storage.delete_document(session, doc_id, skip_quota=is_cloud)
# auto_commit=False defers the commit so the audit log write below happens
# in the same transaction — avoids the split-transaction gap (WR-08).
ok = await storage.delete_document(session, doc_id, skip_quota=is_cloud, auto_commit=False)
if not ok:
raise HTTPException(404, "Document not found")
# D-13: document deleted event — written AFTER successful delete, size_bytes only (T-04-07-02)
# D-13: document deleted event — written in the same transaction as the delete (WR-08).
await write_audit_log(
session,
event_type="document.deleted",