Repository navigation
Set end date and duration on tasks skipped by a Dag run timeout - #74128
Merged
shahar1 merged 2 commits intoOct 3, 2026
Merged
Conversation
When a Dag run hits dagrun_timeout, the scheduler skips the task that is still running but never sets its end_date or duration, so the elapsed time shown for it keeps growing. This test fails until the timeout path sets both.
The timeout branch of SchedulerJobRunner._schedule_dag_run assigned SKIPPED directly, so a task that was running kept its start_date with no end_date or duration, and the elapsed time shown for it kept growing. Use TaskInstance.set_state, which every other skip path goes through: it sets end_date and duration, and gives a task that never started the same start and end date.
shahar1
approved these changes
Oct 3, 2026
shahar1
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Compared to past PRs, this one seems the cleanest and with appropriate testing.
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
Contributor
|
Thanks for fixing this! #71549 originally had this same |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a Dag run hits
dagrun_timeout, the scheduler skips the task that is still running but leaves itsend_dateanddurationempty, so the elapsed time shown for it keeps growing after the task is gone.The timeout branch of
SchedulerJobRunner._schedule_dag_runset the state directly. It now callsTaskInstance.set_state, like the other skip paths, which setsend_dateandduration. 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 sdagrun_timeoutand a task that sleeps 120 s, read 150 s after that task started: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_stateto 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?
Generated-by: Claude Code (Opus 5.5) following the guidelines