You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "FrankYang0529 (via GitHub)" <gi...@apache.org> on 2026/09/12 12:23:44 UTC
[PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
FrankYang0529 opened a new pull request, #73032:
URL: https://github.com/apache/airflow/pull/73032
## Why
- The scheduler recomputes `DagModel.exceeds_max_non_backfill` when a Dag run finishes, but only for `scheduled`, `manual` and `asset_triggered` runs. The flag itself counts every active run except backfill runs.
- `asset_materialization` (#62276) and `operator_triggered` (#63733) came after #60006 introduced that list, and were never added to it.
- When one of these runs is the last active run of a Dag at its `max_active_runs` limit, the flag stays `True` after the run finishes. The scheduler skips the Dag until the Dag processor parses the file again, so scheduled and asset-triggered runs start late.
## How
- Recompute the flag for every finished run except backfill runs, which matches what the flag counts.
## Verification
- Unit test: `breeze run pytest airflow-core/tests/unit/jobs/test_scheduler_job.py`
- Integration test:
1. Setup
```sh
mkdir -p files/dags
cat > files/dags/demo_dags.py <<'EOF'
from __future__ import annotations
import datetime
from airflow.providers.standard.operators.bash import BashOperator
from airflow.providers.standard.operators.trigger_dagrun import TriggerDagRunOperator
from airflow.sdk import DAG
START = datetime.datetime(2026, 1, 1, tzinfo=datetime.timezone.utc)
with DAG(dag_id="demo_child", schedule="* * * * *", start_date=START, catchup=False, max_active_runs=1):
BashOperator(task_id="work", bash_command="sleep 60")
with DAG(dag_id="demo_parent", schedule=None, start_date=START, catchup=False):
TriggerDagRunOperator(
task_id="trigger_child",
trigger_dag_id="demo_child",
trigger_run_id="triggered_by_parent",
)
EOF
```
2. Start Airflow
```sh
breeze shell --backend sqlite
```
```sh
export AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=sqlite:////tmp/demo.db
export AIRFLOW__CORE__LOAD_EXAMPLES=False
export AIRFLOW__DAG_PROCESSOR__MIN_FILE_PROCESS_INTERVAL=600
airflow standalone > /tmp/standalone.log 2>&1 &
```
3. Trigger Dag
```
airflow dags list
airflow dags unpause demo_parent
airflow dags unpause demo_child
```
Run this until a `scheduled__...` run is `running`:
```bash
airflow dags list-runs demo_child
```
Trigger `demo_parent`. Its run of `demo_child` queues behind the running scheduled run.
```bash
airflow dags trigger demo_parent
```
On main branch, after `triggered_by_parent` is `success`, the next run is not scheduled on the next minute. The scheduler skips `demo_child` until the Dag processor parses the file again.
```text
dag_id | run_id | state | run_after | logical_date | start_date | end_date
===========+========================+=========+=======================+========================+=======================+========================
demo_child | scheduled__2026-09-12T | success | 2026-09-12T11:35:00+0 | 2026-09-12T11:35:00+00 | 2026-09-12T11:35:42.6 | 2026-09-12T11:36:43.762
| 11:35:00+00:00 | | 0:00 | :00 | 14960+00:00 | 543+00:00
demo_child | triggered_by_parent | success | 2026-09-12T11:26:17.9 | 2026-09-12T11:26:17.76 | 2026-09-12T11:27:02.6 | 2026-09-12T11:28:03.737
| | | 12138+00:00 | 8602+00:00 | 28857+00:00 | 794+00:00
demo_child | scheduled__2026-09-12T | success | 2026-09-12T11:25:00+0 | 2026-09-12T11:25:00+00 | 2026-09-12T11:25:58.5 | 2026-09-12T11:27:01.604
| 11:25:00+00:00 | | 0:00 | :00 | 15063+00:00 | 410+00:00
```
On this branch, the next run is scheduled as expected.
```text
dag_id | run_id | state | run_after | logical_date | start_date | end_date
===========+========================+=========+=======================+========================+=======================+========================
demo_child | scheduled__2026-09-12T | success | 2026-09-12T12:17:00+0 | 2026-09-12T12:17:00+00 | 2026-09-12T12:18:17.1 | 2026-09-12T12:19:18.314
| 12:17:00+00:00 | | 0:00 | :00 | 51901+00:00 | 029+00:00
demo_child | triggered_by_parent | success | 2026-09-12T12:16:44.2 | 2026-09-12T12:16:44.10 | 2026-09-12T12:17:14.9 | 2026-09-12T12:18:16.125
| | | 88514+00:00 | 9705+00:00 | 91149+00:00 | 626+00:00
demo_child | scheduled__2026-09-12T | success | 2026-09-12T12:16:00+0 | 2026-09-12T12:16:00+00 | 2026-09-12T12:16:11.0 | 2026-09-12T12:17:13.975
| 12:16:00+00:00 | | 0:00 | :00 | 11254+00:00 | 608+00:00
```
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
<!--
Thank you for contributing!
Please provide above a brief description of the changes made in this pull request.
Write a good git commit message following this guide: https://chris.beams.io/posts/git-commit/
Please make sure that your code changes are covered with tests.
And in case of new features or big changes remember to adjust the documentation.
For user-facing UI changes, please attach before/after screenshots (or a short
screen recording) so reviewers can assess the visual impact.
Feel free to ping (in general) for the review if you do not see reaction for a few days
(72 Hours is the minimum reaction time you can expect from volunteers) - we sometimes miss notifications.
In case of an existing issue, reference it using one of the following:
* closes: #ISSUE
* related: #ISSUE
-->
---
##### Was generative AI tooling used to co-author this PR?
<!--
If generative AI tooling has been used in the process of authoring this PR, please
change below checkbox to `[X]` followed by the name of the tool, uncomment the "Generated-by".
-->
- [X] Yes - Claude Code
<!--
Generated-by: [Tool Name] following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
-->
---
* Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#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](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
* When adding dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
* For significant user-facing changes create newsfragment: `{pr_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments). You can add this file in a follow-up commit after the PR is created so you know the PR number.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil merged PR #73032:
URL: https://github.com/apache/airflow/pull/73032
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "phillip-parrott (via GitHub)" <gi...@apache.org>.
phillip-parrott commented on PR #73032:
URL: https://github.com/apache/airflow/pull/73032#issuecomment-6016559228
For bug fixes like this, how long until this would take to make it to a release? This is causing major infrastructure issues for us since the upgrade and would like to have an idea on a rough timeline
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #73032:
URL: https://github.com/apache/airflow/pull/73032#issuecomment-5839148941
Hello @FrankYang0529 - thank you for your contributions to Apache Airflow!
The Airflow community has introduced a limit of **5 open pull requests at a time** for contributors without write access to the repository. You currently have 30 open pull requests, so - as a one-time step of introducing the limit - we closed the ones where maintainers have not engaged yet:
* #69698 - Avoid deactivating configured Dag bundles on transient get bundle errors
* #71678 - Add gzip compression option for GCS remote task logs
* #71775 - Fix comma-separated selected_fields in BigQuery to SQL transfers
* #71837 - Fix the API server silently ignoring its gunicorn worker hooks
* #72027 - Fix docs omitting asset from the Dag discovery safe-mode heuristic
* #72104 - Add missing Druid Ingest connection type
* #72138 - Fix scheduler crash when the Kafka event producer plugin is enabled
* #72153 - Fix unscheduled tasks left on a stale Dag version
* #72317 - Make AzureBatchOperator batch_max_retries take effect
* #72593 - Fix airflow.utils.context deprecation shim returning a module object
* #72626 - Support team-scoped secrets in LocalFilesystemBackend
* #72802 - Honour dag_ignore_file_syntax in Task SDK and example plugin loading
* #72858 - Restore CLI commands from custom executors and auth managers
* #72884 - Restore helpful error for unregistered priority weight strategies
* #72919 - Fix flaky test_trigger_log in triggerer job tests
* #72920 - Fix API server failing to start when [api] access_logfile is set
* #73020 - Fix missing task display name and map index in API audit logs
* #73029 - Fail Gemini batch job operators when the job does not succeed
* #73031 - Fix extra Dag versions from template field callables if paths change
* #73032 - Fix Dags staying blocked by max_active_runs until the next parse
* #73081 - Reject async callables in @task.virtualenv and @task.external_python
* #73136 - Fix env var names in airflow config list for dotted and team sections
* #73247 - Fix OpenLineage jobDependencies run ID after upstream task is cleared
* #73312 - Fix SFTPSensor skipping python_callable in deferrable mode
These pull requests stay open because maintainers are already engaged in them - they count towards your limit:
* #68625 - Add KafkaSharedStreamProducer and KafkaSharedStreamTrigger
* #68778 - Add rerun policy for rollups when an upstream partition is re-run
* #70351 - Replace AirflowException with ValueError in ProduceToTopicOperator
* #71869 - Catch stale entries in the Java SDK dependency trust list
* #72057 - Support priority_weight in EdgeExecutor
* #73021 - Speed up the event logs API by loading only display names
This is **not** a judgement of you or of your changes. We never told contributors before that opening many pull requests at once was a problem, so there is nothing to feel bad about - and nothing is lost: your branches, commits and the review history stay where they are.
What we ask you to do is to make your **first prioritization decision**: choose which of the pull requests above matter most to you, and reopen them (up to 5 open at a time, including the ones still open) with the "Reopen pull request" button or `gh pr reopen <PR_NUMBER> --repo apache/airflow`. Reopen the ones you are ready to follow through - keep them rebased, respond to review comments and fix failing checks.
While your pull requests are waiting for review, the most valuable thing you can do is help in other ways - reviewing other contributors' pull requests, helping with issues, and taking part in the discussions on the devlist and Slack.
Why we introduced the limit, what it means for you and how to reopen or restore a pull request is explained in https://github.com/apache/airflow/blob/main/contributing-docs/32_open_pull_request_limit.rst.
---
Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk closed pull request #73032: Fix Dags staying blocked by max_active_runs until the next parse
URL: https://github.com/apache/airflow/pull/73032
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "phillip-parrott (via GitHub)" <gi...@apache.org>.
phillip-parrott commented on PR #73032:
URL: https://github.com/apache/airflow/pull/73032#issuecomment-6012171905
@potiuk fyi you also mentioned that PRs would be closed if maintainers haven't engaged - yet this was approved and added to airflow 3.4.0 milestone
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "phillip-parrott (via GitHub)" <gi...@apache.org>.
phillip-parrott commented on PR #73032:
URL: https://github.com/apache/airflow/pull/73032#issuecomment-6012094876
Hey, can this PR be opened back up @potiuk ? This is a legitimate issue we're seeing as well since our upgrade to 3.3.2.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #73032:
URL: https://github.com/apache/airflow/pull/73032#discussion_r4195022220
##########
airflow-core/tests/unit/jobs/test_scheduler_job.py:
##########
@@ -6039,34 +6039,42 @@ def test_should_use_info_from_timetable(self, mock_create, mock_next, expected,
)
assert actual == expected
+ @pytest.mark.parametrize("timed_out", [False, True], ids=["finished", "timed_out"])
@pytest.mark.parametrize(
("run_type", "expected"),
[
(DagRunType.MANUAL, True),
(DagRunType.SCHEDULED, True),
(DagRunType.BACKFILL_JOB, False),
(DagRunType.ASSET_TRIGGERED, True),
+ (DagRunType.OPERATOR_TRIGGERED, True),
+ (DagRunType.ASSET_MATERIALIZATION, True),
],
ids=[
DagRunType.MANUAL.name,
DagRunType.SCHEDULED.name,
DagRunType.BACKFILL_JOB.name,
DagRunType.ASSET_TRIGGERED.name,
+ DagRunType.OPERATOR_TRIGGERED.name,
+ DagRunType.ASSET_MATERIALIZATION.name,
],
)
- def test_should_update_dag_next_dagruns_after_run_type(self, run_type, expected, session, dag_maker):
+ def test_should_update_dag_next_dagruns_after_run_type(
Review Comment:
Nit, since this PR already reworks the signature: the name and docstring still describe "next dag run is updated", but since #60006 the thing this test checks is whether `_set_exceeds_max_active_runs` gets called. The `calculate_dagrun_date_fields` patch and `assert not mock_calc.called` are now a no-op: `_schedule_dag_run` no longer calls it, so that assertion passes for every case. Could you rename it to something like `test_exceeds_max_active_runs_recomputed_for_finished_non_backfill_runs`, update the docstring, and drop the `mock_calc` patch? Optionally, `patch.object(SchedulerJobRunner, "_set_exceeds_max_active_runs", autospec=True)` instead of the bare `MagicMock()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "FrankYang0529 (via GitHub)" <gi...@apache.org>.
FrankYang0529 commented on code in PR #73032:
URL: https://github.com/apache/airflow/pull/73032#discussion_r4226070212
##########
airflow-core/tests/unit/jobs/test_scheduler_job.py:
##########
@@ -6039,34 +6039,42 @@ def test_should_use_info_from_timetable(self, mock_create, mock_next, expected,
)
assert actual == expected
+ @pytest.mark.parametrize("timed_out", [False, True], ids=["finished", "timed_out"])
@pytest.mark.parametrize(
("run_type", "expected"),
[
(DagRunType.MANUAL, True),
(DagRunType.SCHEDULED, True),
(DagRunType.BACKFILL_JOB, False),
(DagRunType.ASSET_TRIGGERED, True),
+ (DagRunType.OPERATOR_TRIGGERED, True),
+ (DagRunType.ASSET_MATERIALIZATION, True),
],
ids=[
DagRunType.MANUAL.name,
DagRunType.SCHEDULED.name,
DagRunType.BACKFILL_JOB.name,
DagRunType.ASSET_TRIGGERED.name,
+ DagRunType.OPERATOR_TRIGGERED.name,
+ DagRunType.ASSET_MATERIALIZATION.name,
],
)
- def test_should_update_dag_next_dagruns_after_run_type(self, run_type, expected, session, dag_maker):
+ def test_should_update_dag_next_dagruns_after_run_type(
Review Comment:
Sorry for late. I create a follow-up PR https://github.com/apache/airflow/pull/74483.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on code in PR #73032:
URL: https://github.com/apache/airflow/pull/73032#discussion_r4195431833
##########
airflow-core/tests/unit/jobs/test_scheduler_job.py:
##########
@@ -6039,34 +6039,42 @@ def test_should_use_info_from_timetable(self, mock_create, mock_next, expected,
)
assert actual == expected
+ @pytest.mark.parametrize("timed_out", [False, True], ids=["finished", "timed_out"])
@pytest.mark.parametrize(
("run_type", "expected"),
[
(DagRunType.MANUAL, True),
(DagRunType.SCHEDULED, True),
(DagRunType.BACKFILL_JOB, False),
(DagRunType.ASSET_TRIGGERED, True),
+ (DagRunType.OPERATOR_TRIGGERED, True),
+ (DagRunType.ASSET_MATERIALIZATION, True),
],
ids=[
DagRunType.MANUAL.name,
DagRunType.SCHEDULED.name,
DagRunType.BACKFILL_JOB.name,
DagRunType.ASSET_TRIGGERED.name,
+ DagRunType.OPERATOR_TRIGGERED.name,
+ DagRunType.ASSET_MATERIALIZATION.name,
],
)
- def test_should_update_dag_next_dagruns_after_run_type(self, run_type, expected, session, dag_maker):
+ def test_should_update_dag_next_dagruns_after_run_type(
Review Comment:
happy for this to be a follow-up
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix Dags staying blocked by max_active_runs until the next parse [airflow]
Posted by "kaxil (via GitHub)" <gi...@apache.org>.
kaxil commented on PR #73032:
URL: https://github.com/apache/airflow/pull/73032#issuecomment-6016595114
> For bug fixes like this, how long until this would take to make it to a release? This is causing major infrastructure issues for us since the upgrade and would like to have an idea on a rough timeline
cc @vatsrahul1001 on timelines but Airflow 3.4 is near the corner
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org