-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Ensure singleton use of DagBag across all API requests
#50447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c22860b to
8159898
Compare
jason810496
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! Initializing DagBag during FastAPI's lifespan event is a thread-safe and cleaner way to achieve a singleton pattern.
I had considered using airflow.utils.singleton.Singleton for this, but the current Singleton utility is not thread-safe. Adding a thread-level lock might introduce performance issues, especially if DagBag initialization takes a long time and blocks other threads.
Previously, DagBag was injected via onlyFastAPI dependency as part of the refactor in apache#50372 , but a new instance was created for each request. This change updates the dependency to resolve DagBag from `app.state`, ensuring it is only instantiated once at startup while keeping benefits of FastAPI dependency.
Previously, DagBag was injected via onlyFastAPI dependency as part of the refactor in #50372 , but a new instance was created for each request. This change updates the dependency to resolve DagBag from `app.state`, ensuring it is only instantiated once at startup while keeping benefits of FastAPI dependency. (cherry picked from commit 3b49f9d)
Previously, DagBag was injected via onlyFastAPI dependency as part of the refactor in #50372 , but a new instance was created for each request. This change updates the dependency to resolve DagBag from `app.state`, ensuring it is only instantiated once at startup while keeping benefits of FastAPI dependency. (cherry picked from commit 3b49f9d)
Previously, DagBag was injected via onlyFastAPI dependency as part of the refactor in apache#50372 , but a new instance was created for each request. This change updates the dependency to resolve DagBag from `app.state`, ensuring it is only instantiated once at startup while keeping benefits of FastAPI dependency.
Previously, DagBag was injected via onlyFastAPI dependency as part of the refactor in #50372, but a new instance was created for each request. This change updates the dependency to resolve DagBag from
app.state, ensuring it is only instantiated once at startup while keeping benefits of FastAPI dependency.^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.