Skip to content

Keep backfill authorization off the API server event loop - #76493

Open
aaron-y-chen wants to merge 2 commits into
apache:mainfrom
aaron-y-chen:fix-76425-backfill-off-event-loop
Open

aaron-y-chen wants to merge 2 commits into
apache:mainfrom
aaron-y-chen:fix-76425-backfill-off-event-loop

Conversation

@aaron-y-chen

Copy link
Copy Markdown
Contributor

related: #76425

requires_access_backfill is an async dependency, but it looked up the backfill's Dag through the route's sync session, and on a team-name cache miss it also looked up the Dag's team through the sync DagModel.get_team_name. Both calls waited for a pooled connection on the event loop, so once the pool was busy they could stall the whole API server in the same way as #76417. Every /backfills/{backfill_id} route ran the first lookup on every request. The team lookup also ran on routes that name the Dag in the query string or the body (GET /backfills?dag_id=, GET /ui/backfills?dag_id=, POST /backfills, POST /backfills/dry_run). The sweep in #76424 doesn't reach those routes because it sends no dag_id, so the new route tests seed a backfill and cover both cases.

Both lookups now run on an async session. DagModel.get_team_name_async shares the existing team-name cache with get_team_name, so a value cached by one is served to the other.

This builds on #76424: it removes the backfill lines from generated/known_sync_db_on_event_loop.txt and uses that PR's event_loop_queries fixture. Until #76424 is merged, the first commit here is a copy of it, so please review only the last commit. I'll drop that copy and rebase onto main once #76424 is merged.


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

Generated-by: Claude Code (Opus 5.5) following the guidelines

@github-actions github-actions Bot added the fork ci required Gated by AIP-120: CI must pass in the contributor's fork. Managed by the fork CI reconciler. label Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fork CI: green. CI for the latest commit passed in your fork. The pull request is ready for maintainer review.

Pull requests from contributors run their CI in the contributor's own fork. GitHub Actions is free and has no minute limit on public forks, while the CI capacity of the Apache Software Foundation is shared by every ASF project and is finite.

Fork CI tested this branch merged with main at d85450b3b9, as project CI would, 0 commits behind main when the run turned green.

Latest run: https://github.com/aaron-y-chen/airflow/actions/runs/45531909484

How this works: CI in your fork.


This comment was posted automatically by the fork CI monitor from templates drafted with an AI-assisted tool, so it may contain mistakes. An Apache Airflow maintainer, a real person, will review the pull request once its fork CI is green. Why the first pass is automated.

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

I see that the PR is in draft @aaron-y-chen anything missing before we take a look ?

@aaron-y-chen

Copy link
Copy Markdown
Contributor Author

Hi @pierrejeambrun, thanks for asking! this PR is build on #76424: the first commit is copy of that PR, so I'm waiting for it to be reviewed before rebasing this one.

The last commit (4ebeb58) has all of this PR's changes, so feel free to review it in the meantime :)

@aaron-y-chen
aaron-y-chen force-pushed the fix-76425-backfill-off-event-loop branch from 4ebeb58 to bfcb88a Compare November 17, 2026 17:34
@aaron-y-chen
aaron-y-chen marked this pull request as ready for review November 17, 2026 18:31
@github-actions github-actions Bot added the ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. label Nov 17, 2026

@jason810496 jason810496 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.

Thanks for the PR, one primary comment regarding the session lifecycle.

Comment thread airflow-core/src/airflow/models/dag.py Resolved
@aaron-y-chen

Copy link
Copy Markdown
Contributor Author

Thanks @jason810496 , both suggestions were really helpful! I've addressed them in my latest commit. Let me know if anything else needs improving :)

@github-actions github-actions Bot added ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. and removed ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green. labels Nov 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork ci required Gated by AIP-120: CI must pass in the contributor's fork. Managed by the fork CI reconciler. ready for maintainer review Set by triage when all criteria pass, or by the fork CI reconciler when fork CI is green.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants