ChickenBenny opened a new pull request, #77599:
URL: https://github.com/apache/airflow/pull/77599
related: #76425
---
<!-- SPDX-License-Identifier: Apache-2.0
https://www.apache.org/licenses/LICENSE-2.0 -->
When `[fab] auth_role_public` is set, `FabAuthRolePublicMiddleware` builds
the public user for every request that carries no JWT. Its `dispatch` is async,
but `build_public_user` ran the role and permission query through a sync
session. That blocked the event loop on a pooled connection for every anonymous
request. When the pool is full, the loop stalls and the requests that hold
connections can't release them, the same failure as #76417. This one is also
reachable without authentication.
`build_public_user` is now async and reads the role through
`create_session_async()`. `Role.permissions` and `Permission.action`/`resource`
are already `lazy="joined"`, so the single query still loads everything the
returned user needs after the session closes.
`test_event_loop_blocking.py` runs in airflow-core with the default auth
manager, so FAB's public-role middleware is never exercised there. A new FAB
test fails if `build_public_user` runs any statement through a sync engine.
Each anonymous request still runs one query, now on the async engine, with
no cache in front of it, same as before this change. Caching the public role
(e.g. under `[fab] cache_ttl`) can be a follow-up if needed.
`build_public_user` is `:meta private:`; it is now a coroutine and no longer
takes `session`.
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Code (Opus 5.5) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]