Skip to content

Avoid N+1 team-name queries in bulk Dag run authorization#68286

Merged
pierrejeambrun merged 5 commits into
apache:mainfrom
yuseok89:batch-dag-run-team-lookup
Jun 10, 2026
Merged

Avoid N+1 team-name queries in bulk Dag run authorization#68286
pierrejeambrun merged 5 commits into
apache:mainfrom
yuseok89:batch-dag-run-team-lookup

Conversation

@yuseok89

@yuseok89 yuseok89 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

_build_dag_run_access_requests() (bulk Dag run authorization) resolved each Dag's team with a per-Dag DagModel.get_team_name() call. It now uses the existing batched DagModel.get_dag_id_to_team_name_mapping() — one query for all Dags.

Team-name queries when authorizing N distinct Dags (cold cache):

Before After
N Dags N 1
no Dags 0 0 (skipped)

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)
    • Opus 4.8

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

@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Jun 9, 2026

@henry3260 henry3260 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good!

Comment thread airflow-core/tests/unit/api_fastapi/core_api/test_security.py
Comment thread airflow-core/tests/unit/api_fastapi/core_api/test_security.py Outdated
Comment thread airflow-core/src/airflow/api_fastapi/core_api/security.py Outdated

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

@pierrejeambrun pierrejeambrun merged commit 40b6796 into apache:main Jun 10, 2026
77 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants