aminghadersohi commented on code in PR #45029:
URL: https://github.com/apache/superset/pull/45029#discussion_r4213151667


##########
superset/tasks/deletion_retention.py:
##########
@@ -342,6 +492,48 @@ def _finalize_blocked(record_id: UUID | None, blocker: 
BlockerReason) -> None:
         )
 
 
+def _confirm_committed_purge(record_id: UUID | None, result: CascadeResult) -> 
None:
+    """Keep a committed root counted even if audit finalization fails."""
+    try:
+        audit.confirm(
+            record_id,
+            affected_referrers=result.dangling_chart_uuids,
+            removed_dashboard_slices=result.removed_dashboard_slices,
+        )
+    except Exception:  # pylint: disable=broad-except
+        # The audit remains pending for its normal reconciliation path.
+        logger.exception(
+            "deletion_retention: audit finalization failed after committed 
purge"
+        )
+
+
+def _commit_purge_root(record_id: UUID | None) -> None:
+    """Commit a purge, keeping uncertain outcomes pending for 
reconciliation."""
+    try:
+        db.session.commit()  # pylint: disable=consider-using-transaction
+    except Exception as exc:
+        try:
+            db.session.rollback()  # pylint: disable=consider-using-transaction
+        except Exception:  # pylint: disable=broad-except
+            logger.exception("deletion_retention: rollback after commit error 
failed")
+            raise _PurgeCommitUncertainError(

Review Comment:
   No test covers this rollback-failure branch: change it to `raise exc` and 
all 175 tests pass, yet `_purge_model` then purges the next roots and counts 
the possibly-committed root as a failure. A case with a failing commit then a 
failing rollback should assert the run stops.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to