xchwan commented on code in PR #75708:
URL: https://github.com/apache/airflow/pull/75708#discussion_r4490349771
##########
airflow-core/src/airflow/serialization/definitions/dag.py:
##########
@@ -836,6 +837,15 @@ def _process_dagrun_deadline_alerts(
)
stats.incr("deadline_alerts.deadline_creation_failed",
tags=metrics_tags)
+ # An alert can roll the session back, discarding the pending
DagRun. Carrying on would
+ # add Deadlines that violate the dagrun_id foreign key, and
returning normally would let
+ # the caller treat the missing run as created.
+ if orm_dagrun not in session:
Review Comment:
You're right. The asset-triggered and partitioned asset paths now catch
`DagRunRolledBackError` too, log `Failed creating DagRun` and move on, so the
scheduler no longer exits. Both leave their state untouched, so the run is
retried on the next tick. I added a test for each.
Checked in Breeze (Postgres, real scheduler), once per creation path with a
Dag whose alert rolls back the session. Without the change the scheduler exits
with code 1 on the asset-triggered and partitioned paths; with it, all three
paths keep the scheduler running and log `Failed creating DagRun` on every
tick. The scheduled path already caught the error.
As noted in the description, the rollback itself still can't be undone from
here, so runs other Dags added earlier in the same tick are discarded along
with it.
---
Drafted-by: Claude Code (Sonnet 5.5); reviewed by @xchwan
--
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]