diff --git a/control-pipeline/services/decomposition_pass.py b/control-pipeline/services/decomposition_pass.py index 998c52b..9aa58a7 100644 --- a/control-pipeline/services/decomposition_pass.py +++ b/control-pipeline/services/decomposition_pass.py @@ -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