Skip to content

When a dagrun is cleared, recalculate related deadlines if applicable.#61372

Open
ferruzzi wants to merge 2 commits intoapache:mainfrom
aws-mwaa:ferruzzi/deadlines/recalculate-on-clear
Open

When a dagrun is cleared, recalculate related deadlines if applicable.#61372
ferruzzi wants to merge 2 commits intoapache:mainfrom
aws-mwaa:ferruzzi/deadlines/recalculate-on-clear

Conversation

@ferruzzi
Copy link
Contributor

@ferruzzi ferruzzi commented Feb 2, 2026

bugfix - If the run has a deadline related to the queued_at time, then those should be recalculated when that timestamp is changed.

Manually tested by starting a dag with a deadline and watching the dagrun.queued_at and deadline.deadline_time columns before and after a run cleared via the Airflow UI.

cc @ramitkataria @seanghaeli


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • 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.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

If the run has a deadline related to the queued_at time, then those should be recalculated when that timestamp is changed.
deadline.deadline_time,
new_deadline_time,
)
deadline.deadline_time = new_deadline_time
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not we commit the new deadline time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I don't think so. My understanding is that committing or flushing here would break the scheduler session's atomic nature and could result in the database getting a partial update if things went wrong. When I tested manually, this does work as expected. deadline.deadline_time = new_deadline_time is saving that value int he ORM, and the session.flush() on/around L349 writes it all at once.

This pattern also matches how the DagRun updates are handled earlier in the same function (like dr.clear_number += 1 and dr.queued_at = ...).

I'm definitely not an SQL expert, but I'm reasonably confident that this is good how it is.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants