fix: use fresh session in FabAuthManager.deserialize_user (#62903)#62930
Closed
davidfrickert wants to merge 2 commits into
Closed
fix: use fresh session in FabAuthManager.deserialize_user (#62903)#62930davidfrickert wants to merge 2 commits into
davidfrickert wants to merge 2 commits into
Conversation
FabAuthManager.deserialize_user was using self.session (FAB's
appbuilder-scoped SQLAlchemy session). When that session becomes
poisoned after a DB connection drop, the next request on the same
worker raises an error due to attempting to use dropped connection. This can cause a Internal Server Error to the user.
Replace self.session with create_session() so each cache miss gets a
fresh, short-lived session that is closed immediately after the query.
Also replace the @cachedmethod decorator with an explicit cache check
using a namespaced tuple key ("user", user_id) to preserve caching functionality.
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
Contributor
|
#62919 is already working on fixing the issue. Closing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FabAuthManager.deserialize_user was using self.session (FAB's appbuilder-scoped SQLAlchemy session). When that session becomes poisoned after a DB connection drop, the next request on the same worker raises an error due to attempting to use dropped connection. This can cause a Internal Server Error to the user.
Replace self.session with create_session() so each cache miss gets a fresh, short-lived session that is closed immediately after the query. Also replace manual query with
getfunction which returns an optional value instead of exception when not found.Was generative AI tooling used to co-author this PR?
Used Claude code. Reviewed code and tested.
Fixes #62903
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.