fix: Pass 0b INSERT ON CONFLICT DO UPDATE + per-result commit/rollback
Prevents UniqueViolation from blocking entire batch. Each result is committed individually, errors are rolled back without affecting subsequent results. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3314,6 +3314,11 @@ class DecompositionPass:
|
||||
CAST(:framework_id AS uuid),
|
||||
'pass0b', 2
|
||||
)
|
||||
ON CONFLICT (framework_id, control_id) DO UPDATE
|
||||
SET title = EXCLUDED.title,
|
||||
objective = EXCLUDED.objective,
|
||||
requirements = EXCLUDED.requirements,
|
||||
updated_at = NOW()
|
||||
RETURNING id::text
|
||||
"""),
|
||||
{
|
||||
@@ -3686,11 +3691,19 @@ class DecompositionPass:
|
||||
self._handle_batch_result_0a(custom_id, text_content, stats)
|
||||
else:
|
||||
await self._handle_batch_result_0b(custom_id, text_content, stats)
|
||||
self.db.commit()
|
||||
except Exception as e:
|
||||
logger.error("Processing batch result %s: %s", custom_id, e)
|
||||
stats["errors"] += 1
|
||||
try:
|
||||
self.db.rollback()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.db.commit()
|
||||
try:
|
||||
self.db.commit()
|
||||
except Exception:
|
||||
pass
|
||||
stats["status"] = "completed"
|
||||
return stats
|
||||
|
||||
|
||||
Reference in New Issue
Block a user