Skip to content

Enhance max active runs log - #72389

Closed
yquaziii wants to merge 277 commits into
apache:mainfrom
yquaziii:enhance-max-active-runs-log
Closed

Enhance max active runs log#72389
yquaziii wants to merge 277 commits into
apache:mainfrom
yquaziii:enhance-max-active-runs-log

Conversation

@yquaziii

@yquaziii yquaziii commented Sep 1, 2026

Copy link
Copy Markdown

Description

Currently, when a DAG reaches its max_active_runs limit, the scheduler logs a generic message:
DAG <dag_id> is at (or above) max_active_runs (<X> of <Y>), not creating any more runs

While this indicates that the limit has been reached, it does not provide any context about what is occupying those active slots. To figure out why the DAG is stuck, users currently have to manually navigate through the Airflow UI or query the metadata database to find the hanging runs and tasks.

This PR:
Enhances the log message in scheduler_job_runner.py. When the max_active_runs limit is hit, the scheduler will perform targeted queries to fetch the specific run_ids and task_ids (along with their current states) that are holding the active slots.

New Log Output Example:
DAG test_dag is at (or above) max_active_runs (1 of 1), not creating any more runs. Active Runs: scheduled__2023-10-18T09:55:00+00:00 | Active Tasks: [sleep_task in scheduled__2023-10-18T09:55:00+00:00 (running)]

Implementation Note:
To avoid unnecessary database load, the queries to fetch the active runs and tasks are placed strictly inside the if total_active_runs >= dag.max_active_runs: condition. This ensures there is zero performance overhead during normal, healthy scheduling loops.

  • Added unit tests in test_scheduler_job_runner.py to ensure the logging fires with the correct format and data.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    Generated-by Google Antigravity for checking which files to changes and test.

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

kev-the-dev and others added 30 commits September 2, 2024 17:09
Co-authored-by: Amogh Desai <amoghrajesh1999@gmail.com>
Co-authored-by: obarisk <obarisk@yiyixiu.idv.tw>
Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
* Adding rel property to hyperlinks in logs

* fixing tests

(cherry picked from commit 79db243)
Bumps [micromatch](https://github.com/micromatch/micromatch) from 4.0.5 to 4.0.8.
- [Release notes](https://github.com/micromatch/micromatch/releases)
- [Changelog](https://github.com/micromatch/micromatch/blob/4.0.8/CHANGELOG.md)
- [Commits](micromatch/micromatch@4.0.5...4.0.8)

---
updated-dependencies:
- dependency-name: micromatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit e02052b)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* chore(docs): add an example for auth with keycloak

Added a new section in the authentication documentation that provides a code of configuring Airflow to work with Keycloak.

* chore(docs): add an example for auth with keycloak

Fix spelling and styling

* chore(docs): add an example for auth with keycloak

Fix static checks

Co-authored-by: Natsu <34879762+hoalongnatsu@users.noreply.github.com>
)

(cherry picked from commit 83ba17f)

Co-authored-by: Jens Scheffler <95105677+jscheffl@users.noreply.github.com>
* Never fail an ltj over a heartbeat

* Log a warning on failed heartbeat

* Avoid using f-string in log

* Remove unnecessary pass statement

(cherry picked from commit 6647610)

Co-authored-by: Collin McNulty <collin.mcnulty@gmail.com>
…1809)

* Fix: Keep compatibility with old FAB versions (#41549)

* Fix: Tests after #41549 (Keep compatibility with old FAB versions)

* Fix test_dag and test_dagbag
…rrors (#41715) (#41820)

(cherry picked from commit 1c53961)

Co-authored-by: Jens Scheffler <95105677+jscheffl@users.noreply.github.com>
…41829)

* Fix: DAGs are not marked as stale if the AIRFLOW__CORE__DAGS_FOLDER changes

* Update airflow/dag_processing/manager.py

* Add testcase

* Add code comment

* Update code comment

* Update the logic for checking the current dag_directory

* Update testcases

* Remove unwanted code

* Uncomment code

* Add processor_subdir when creating processor_subdir

* Fix test_retry_still_in_executor test

* Remove config from test

* Update airflow/dag_processing/manager.py

Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>

* Update if condition for readability

---------

Co-authored-by: Jed Cunningham <66968678+jedcunningham@users.noreply.github.com>
(cherry picked from commit 9f30a41)
…r as True. (#41834)

Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
* logout link in no roles error page fix

* review comments

(cherry picked from commit 032ac87)

Co-authored-by: Gagan Bhullar <g.deepsingh1@gmail.com>
…1874)

Earlier PR create to address the issue was not handling the case for the Example Dags, due to which the example dags were marked as stale since they are not present in the dag_directory. This PR handles that scenarios and update the testcase accordingly.

related: #41432
(cherry picked from commit 435e968)
Bumps [webpack](https://github.com/webpack/webpack) from 5.76.0 to 5.94.0.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](webpack/webpack@v5.76.0...v5.94.0)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
(cherry picked from commit e8888fe)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
#41890)

(cherry picked from commit 87a4a51)

Co-authored-by: Amogh Desai <amoghrajesh1999@gmail.com>
…#41893) (#41895)

Since the similar test(test_scan_stale_dags_standalone_mode) are skipped in DB isolation mode

(cherry picked from commit 07af14a)
* Update release command for Airflow 2

For airflow 2, we create a branch out of v2-10-test and sync that branch
with v2-10-stable to make a release.

* Update CI check
…41906) (#41927)

(cherry picked from commit f168d0a)

Co-authored-by: Daniel Standish <15932138+dstandish@users.noreply.github.com>
Beacause we pinned universal-pathlib to 0.2.2 in 2.10.0 adding >=
0.2.3 conflicts with currently released PyPI packages. We shoudl
lower it down in order to allow PyPI constraints to not be
conflicting

(cherry picked from commit 351961c)
The test has been updated for DB isolation but the retrieval of
task was not intuitive and it could lead to flaky tests possibly

(cherry picked from commit f25adf1)

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
This also deprecates the public helper functions that powered it. These
will all be removed in Airflow 3 in favor of `dags show`.
They are necessarily dangerous, but simply due to the way they are
integrated into Airflow, their side effects can be pretty impactful.

Co-authored-by: Jed Cunningham <jedcunningham@apache.org>
@yquaziii

yquaziii commented Sep 1, 2026

Copy link
Copy Markdown
Author

closing this request as it took way to many commits.

Kindly discard it.

@yquaziii yquaziii closed this Sep 1, 2026
@yquaziii
yquaziii deleted the enhance-max-active-runs-log branch September 1, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:dev-tools area:helm-chart Airflow Helm Chart area:production-image Production image improvements and fixes backport-to-v3-3-test Backport to v3-3-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.