luc-pimentel opened a new pull request, #74128: URL: https://github.com/apache/airflow/pull/74128
When a Dag run hits `dagrun_timeout`, the scheduler skips the task that is still running but leaves its `end_date` and `duration` empty, so the elapsed time shown for it keeps growing after the task is gone. The timeout branch of `SchedulerJobRunner._schedule_dag_run` set the state directly. It now calls `TaskInstance.set_state`, like the other skip paths, which sets `end_date` and `duration`. A task that never started gets the same start and end date and a zero duration, as when a trigger rule skips it. Tested on 3.3.2 and main with `airflow standalone`, using a Dag with a 30 s `dagrun_timeout` and a task that sleeps 120 s, read 150 s after that task started: | Task | Before | With this change | | --- | --- | --- | | running when the run timed out | skipped, no end date or duration, elapsed time keeps growing | skipped, ends at the timeout, 29 s | | downstream, never started | skipped, no dates | skipped, same start and end, 0 s | Both new tests fail without this change. #58588, #63250 and #71549 fixed the same issue and were closed before merging. #71549 set the fields inline so the batch flushes once; I used `set_state` to keep a single code path, and can switch to the inline version if you prefer. closes: #58536 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Opus 5.5) Generated-by: Claude Code (Opus 5.5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
