Repository navigation
Update waiting tasks to the latest Dag version - #74592
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The targeted SQL fix is correct and has regression coverage for the reported scheduling scenarios.
0 open findings
What changed in this PR
Fixes stale Dag-version associations for waiting task instances in unversioned Dag runs.
Changes:
- Includes
NULLtask states in unfinished-task version updates. - Adds regression coverage for running and deferred upstream tasks.
| File | Description |
|---|---|
scheduler_job_runner.py |
Updates waiting task instances to the latest Dag version. |
test_scheduler_job.py |
Verifies waiting and subsequently scheduled tasks retain the latest version. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ashb
approved these changes
Oct 12, 2026
amoghrajesh
approved these changes
Oct 12, 2026
kaxil
reviewed
Oct 12, 2026
kaxil
approved these changes
Oct 12, 2026
Waiting task instances in unversioned Dag runs can retain stale version references after a Dag update, even when their upstream tasks already reference the new version. This leaves misleading version metadata when the downstream tasks are eventually scheduled.
The regression test should reject an overly broad version update while still proving that waiting tasks receive the latest version.
hussein-awala
force-pushed
the
fix-waiting-task-dag-version
branch
from
October 12, 2026 18:35
d6a1e01 to
6b647ff
Compare
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.
Summary
Fix stale Dag-version associations on waiting task instances when an unversioned Dag changes during an active run.
For a local, unversioned bundle, a downstream task can start after its upstream task but still display an older Dag version. The upstream task's version reference is updated while the waiting downstream task's reference is left unchanged.
Root cause
For runs without a pinned bundle version,
_verify_integrity_if_dag_changed()updates unfinished task instances using:Although
State.unfinishedincludes PythonNone, SQLIN (..., NULL)does not match rows whose state isNULL. Task instances waiting for their upstream dependencies can therefore be excluded from the version update, while running or deferred tasks receive the latest version.Subsequent integrity checks can return early once the latest version is associated with any task instance or task-instance history record in the run, allowing the stale association to persist.
Generic reproduction
upstream >> downstreamand start a run.upstreamrunning or deferred, withdownstreamstill instate=None.upstreamreferences the new version butdownstreamretains the old one.Expected: both unfinished task instances reference the new Dag version, including the downstream task before it becomes schedulable.
Changes
TI.state.is_(None)in the existing unfinished-task update filter.The fix preserves the existing Dag/run scope and versioned-bundle guard. It changes task-instance version metadata; it does not add source-file versioning to local bundles or retroactively repair previously inconsistent runs. A displayed Dag version alone is not proof of the source revision executed by a worker using an unversioned bundle.
Validation
Reproduced on a local
maincheckout atef9feefd83:The publication branch was then based on newer upstream
main. Fast pre-commit checks, including the airflow-core mypy hook, and applicable manual checks passed for the two changed files. Ruff formatting/linting andgit diff --checkalso passed.Was generative AI tooling used to co-author this PR?
Generated-by: pi (OpenAI GPT-6 Astra) following the guidelines