When a dagrun is cleared, recalculate related deadlines if applicable.#61372
When a dagrun is cleared, recalculate related deadlines if applicable.#61372ferruzzi wants to merge 2 commits intoapache:mainfrom
Conversation
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 |
There was a problem hiding this comment.
Should not we commit the new deadline time?
There was a problem hiding this comment.
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.
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?
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.