Read fresh Dag bundle state during refresh#69830
Merged
vatsrahul1001 merged 2 commits intoJul 24, 2026
Merged
Conversation
ephraimbuddy
approved these changes
Jul 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to ensure Dag Processor bundle refresh logic reads up-to-date DagBundleModel refresh state (last_refreshed, version) even when a SQLAlchemy Session may already have a cached ORM instance in its identity map.
Changes:
- Update
DagFileProcessorManager.get_bundle_state()to select onlylast_refreshedandversioncolumns (row-based) rather than loading an ORM entity, avoiding identity-map staleness. - Add a regression test intended to demonstrate cross-session updates are observed when reusing a session.
- Remove an obsolete TODO related to verifying “fresh record” behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| airflow-core/src/airflow/dag_processing/manager.py | Switch bundle state lookup to a column-only select to avoid ORM identity-map caching. |
| airflow-core/tests/unit/dag_processing/test_manager.py | Add regression coverage for observing updated bundle state after another session updates the row. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
|
LGTM! |
vatsrahul1001
approved these changes
Jul 24, 2026
Contributor
Backport successfully created: v3-3-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
vatsrahul1001
pushed a commit
that referenced
this pull request
Jul 24, 2026
* Read fresh Dag bundle state during refresh * Make Dag bundle state freshness test deterministic --------- (cherry picked from commit dd869c5) Co-authored-by: fat-catTW <124506982+fat-catTW@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
Author
|
Thanks for the review. |
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.
Why:
Dag processors may need to observe Dag bundle refresh state written by another processor while reusing an existing SQLAlchemy session. Loading
DagBundleModelas an ORM entity can return an object already present in the session identity map, which risks reading stalelast_refreshedorversionvalues.Solution:
Select only the needed bundle state columns instead of loading the full ORM entity. This avoids the ORM identity map for this lookup and reads
last_refreshedandversionas row values.Added a regression test that first reads bundle state in one session, updates the same row from another session, and verifies the manager observes the updated values.
Was generative AI tooling used to co-author this PR?
[X]Yes (please specify the tool below)Generated-by: [Codex] following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.