xchwan commented on PR #75708:
URL: https://github.com/apache/airflow/pull/75708#issuecomment-7182260835

   Thanks for the reviews so far. Here is how the design has changed since the 
last push:
   
   1. **Alerts run on their own session.** It is read-only (PostgreSQL/MySQL 
`SET TRANSACTION READ ONLY`, SQLite `PRAGMA query_only`) and never committed. 
An alert that fails or rolls back only affects this session: the alert is 
skipped and the Dag run is still created. With a single-connection pool 
(in-memory SQLite), the alerts use the scheduler's session instead.
   2. **When a reference still breaks the scheduler's session** (it rolls back, 
has a commit rejected, fails a flush, or aborts the transaction on PostgreSQL), 
`create_dagrun` raises `DagRunDiscardedError`. It was renamed from 
`DagRunRolledBackError` because it now covers more than a rollback. The 
scheduler then rolls back and creates no more Dag runs in that loop.
   3. **The Dag is then left out of Dag run creation until the scheduler 
restarts.** Its `next_dagrun_create_after` would otherwise stay the oldest, so 
every loop would end on it, and its rollback would discard the other Dags' runs 
each time. The Dag is excluded in the queries, so it doesn't use up the 
per-loop limits. There is no automatic retry, for two reasons. The cause is 
plugin code, which only changes after a restart. And a retry on a new Dag 
version did not work, because `write_dag` updates versions without task 
instances in place. Queued and running runs of the Dag carry on. The scheduler 
logs this once per Dag, with `run_id` and `deadline_alert_id`, and emits 
`deadline_alerts.dag_run_creation_stopped`.
   
   The description has the details and the known limitations. Verified on kind 
with PostgreSQL: with 2 schedulers, no duplicate runs or integrity errors, and 
after fixing the plugin and restarting the scheduler, the Dag gets runs again.
   
   ---
   Drafted-by: Claude Code (Opus 5.5); reviewed by @xchwan before posting
   


-- 
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]

Reply via email to