You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "jason810496 (via GitHub)" <gi...@apache.org> on 2026/02/22 15:34:51 UTC

[PR] [v3-1-test] Fix race condition in auth manager initialization (#62214) [airflow]

jason810496 opened a new pull request, #62326:
URL: https://github.com/apache/airflow/pull/62326

   * Fix race condition in auth manager initialization
   
   Make create_auth_manager() thread-safe using double-checked locking to prevent concurrent requests from creating multiple auth manager instances. This fixes intermittent 500 errors on /auth/token when multiple requests arrive simultaneously.
   
   Closes: #61108
   
   * Handle auth manager class change in singleton cache
   
   The singleton check now also verifies the cached instance matches the currently configured auth manager class. This prevents stale instances when the config changes (e.g. switching between SimpleAuthManager and FabAuthManager during db upgrade).
   
   * Avoid calling get_auth_manager_cls on every create_auth_manager call
   
   Move get_auth_manager_cls() inside the lock so the fast path is just a None check. Add purge_cached_app() in test_upgradedb to ensure clean state between parametrized cases with different auth manager configs.
   
   * Reset auth manager singleton in get_application_builder
   
   Since get_application_builder creates a fresh Flask app each time, the cached auth manager singleton from a previous app context must be cleared to avoid stale state (e.g. KeyError on AUTH_USER_REGISTRATION).
   
   * Clear auth manager singleton in test fixtures using create_app
   
   Test fixtures that call application.create_app() or get_application_builder() can receive a stale auth manager singleton from a previous test, causing AirflowSecurityManagerV2 to be used instead of FabAirflowSecurityManagerOverride.
   
   Add purge_cached_app() calls to test fixtures across fab, google, and keycloak providers to ensure each test gets a fresh auth manager instance. (cherry picked from commit 5c9171af1a56b5b60bb121537159ceb9c4de9f73)
   
    <!-- 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: http://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.
   
   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".
   -->
   
   - [ ] Yes (please specify the tool below)
   
   <!--
   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` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
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] [v3-1-test] Fix race condition in auth manager initialization (#62214) [airflow]

Posted by "jason810496 (via GitHub)" <gi...@apache.org>.
jason810496 merged PR #62326:
URL: https://github.com/apache/airflow/pull/62326


-- 
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] [v3-1-test] Fix race condition in auth manager initialization (#62214) [airflow]

Posted by "bugraoz93 (via GitHub)" <gi...@apache.org>.
bugraoz93 commented on PR #62326:
URL: https://github.com/apache/airflow/pull/62326#issuecomment-3947410034

   CI not related 


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