Skip to content

fix(scheduler): skip asset-triggered dags without SerializedDagModel#64322

Open
leossantos wants to merge 3 commits intoapache:mainfrom
leossantos:fix/asset-queue-missing-serialized-dag-guard
Open

fix(scheduler): skip asset-triggered dags without SerializedDagModel#64322
leossantos wants to merge 3 commits intoapache:mainfrom
leossantos:fix/asset-queue-missing-serialized-dag-guard

Conversation

@leossantos
Copy link
Copy Markdown

Port to main (Airflow 3) of the scheduler guard from #63546: DagModel.dags_needing_dagruns could treat asset-triggered DAGs as ready for a new run when they had AssetDagRunQueue rows but no SerializedDagModel in the same evaluation window. The asset timetable / condition path was not applied consistently for those DAGs, which could allow premature asset-triggered DagRuns while the DAG processor was mid–parse cycle.

This change removes such dag_ids from the in-memory adrq_by_dag / dag_statuses maps until serialization exists. AssetDagRunQueue rows are not deleted; the scheduler can re-evaluate on a later run. A DEBUG log records skipped DAGs (missing serialization). The dags_needing_dagruns docstring documents this behavior.

Tests: two TestDagModel cases cover missing SerializedDagModel (single and multiple DAGs), DEBUG log expectations, sorted dag_id list in the message, and assert asset_dag_run_queue row counts unchanged after dags_needing_dagruns.

related: #63546


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, 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.

…in dags_needing_dagruns

Remove those dag_ids from the in-memory candidate set until serialization
exists; retain AssetDagRunQueue rows and emit DEBUG logs. Add unit tests and
a bugfix newsfragment.
Split DagModel and AssetDagRunQueue inserts and flush after DagModel so foreign-key order matches production DB constraints in TestDagModel.
@leossantos leossantos force-pushed the fix/asset-queue-missing-serialized-dag-guard branch from 0b227b5 to 38a59e0 Compare March 27, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants