Skip to content

fix(scheduler): set end_date on tasks skipped by dagrun timeout - #63250

Closed
YoannAbriel wants to merge 1 commit into
apache:mainfrom
YoannAbriel:fix/issue-58536
Closed

YoannAbriel wants to merge 1 commit into
apache:mainfrom
YoannAbriel:fix/issue-58536

Conversation

@YoannAbriel

@YoannAbriel YoannAbriel commented Mar 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When a DAG run times out via dagrun_timeout, unfinished task instances are marked SKIPPED but their end_date is never set. The UI computes duration as now - start_date, so skipped tasks show a continuously increasing duration — confusing and incorrect.

Root Cause

In SchedulerJobRunner._schedule_dag_run, the timeout handler sets task_instance.state = TaskInstanceState.SKIPPED but doesn't touch end_date. Without an end_date, the UI falls back to computing live duration.

Fix

Set end_date = timezone.utcnow() alongside the state change for all tasks skipped by dagrun timeout. Added a test that creates a timed-out DAG run with running tasks and verifies end_date is populated after the scheduler processes it.

Closes: #58536


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code

Generated-by: Claude Code following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.

Important

🛠️ Maintainer triage note for @YoannAbriel · by @potiuk · 2026-06-18 13:57 UTC

Paused pending your next update — this PR has been inactive for ~65 days, so it's been moved to draft to keep the review queue clear:

  • Rebase on the latest main, address any new failures, and mark it Ready for review when you pick it back up — no rush.
  • See the Pull Request quality criteria.

The ball is in your court — you've been assigned to this PR.

Automated triage — may be imperfect; a maintainer takes the next look.

@potiuk

potiuk commented Mar 10, 2026

Copy link
Copy Markdown
Member

Did you actually check if it works? Or is that change just PR-ed without actually running some real tests? Can you show screenshots and logs from the execution?

@potiuk

potiuk commented Mar 10, 2026

Copy link
Copy Markdown
Member

explanation: This is a vital part of airflow in order to modify scheduler you need to know exactly what you are doing and actually test it.

@YoannAbriel

Copy link
Copy Markdown
Contributor Author

Fair — unit tests only so far. Will set up a local environment with a DAG that hits the timeout path and share logs/screenshots.

@YoannAbriel

Copy link
Copy Markdown
Contributor Author

Reproduced and verified on Airflow 3.1.8 (standalone, SequentialExecutor). Test DAG with dagrun_timeout=timedelta(seconds=30) and 3 tasks chained: quick_task (5s) -> slow_task (120s) -> final_task (5s).

Before fix (unpatched 3.1.8):

Task State end_date
quick_task success 2026-03-11 21:05:05
slow_task skipped None
final_task None None

After fix:

Task State end_date
quick_task success 2026-03-11 21:09:21
slow_task skipped 2026-03-11 21:09:45
final_task None None (never started, expected)

Two lines in _schedule_dag_run — now = timezone.utcnow() and task_instance.end_date = now before merging skipped tasks.

@YoannAbriel
YoannAbriel force-pushed the fix/issue-58536 branch 4 times, most recently from 2b79864 to 64899cc Compare March 16, 2026 16:08
@YoannAbriel
YoannAbriel force-pushed the fix/issue-58536 branch 2 times, most recently from 06edc79 to 6ebc21a Compare March 23, 2026 19:07
@YoannAbriel
YoannAbriel force-pushed the fix/issue-58536 branch 6 times, most recently from 24902f4 to c497cda Compare April 8, 2026 18:05
@potiuk potiuk added the ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. label Apr 8, 2026
@YoannAbriel
YoannAbriel force-pushed the fix/issue-58536 branch 4 times, most recently from 9e738f5 to d817d2a Compare April 10, 2026 09:04
@kaxil
kaxil requested a review from Copilot April 10, 2026 19:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@YoannAbriel
YoannAbriel force-pushed the fix/issue-58536 branch 3 times, most recently from 74c3ea4 to df2246a Compare April 13, 2026 06:06
When a DAG run times out via dagrun_timeout, unfinished tasks are
marked as SKIPPED but end_date was not set. This caused task duration
to keep increasing in the UI even though the task was already skipped.

Set end_date to the current time when marking tasks as SKIPPED during
DAG run timeout handling.

Closes: apache#58536
@potiuk
potiuk marked this pull request as draft June 18, 2026 13:57
@Vamsi-klu

This comment was marked as spam.

@potiuk

potiuk commented Jul 2, 2026

Copy link
Copy Markdown
Member

Note

🗑️ Closing stale draft · by @potiuk · 2026-07-02 18:53 UTC

This draft has been inactive for ~13 days. Closing to keep the queue tidy — no judgment on the change itself. Please reopen (or open a fresh PR) whenever you pick it back up, and a maintainer will be glad to take a look.

Automated triage — may be imperfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:scheduler ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Task duration keeps increasing for skipped tasks due to DAG timeout

4 participants