Skip to content

Commit b3390ac

Browse files
author
simon.meng
committed
Fixed provider FAB - duplicated SQLAlchemy sessions caused transactions fail to close (apache#57065) (apache#57534) (apache#57470)
1 parent a745633 commit b3390ac

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎providers/fab/src/airflow/providers/fab/auth_manager/cli_commands/utils.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
@cache
4343
def _return_appbuilder(app: Flask, db) -> AirflowAppBuilder:
4444
"""Return an appbuilder instance for the given app."""
45-
init_appbuilder(app, enable_plugins=False)
45+
init_appbuilder(app, False, db)
4646
init_plugins(app)
4747
init_airflow_session_interface(app, db)
4848
return app.appbuilder # type: ignore[attr-defined]

‎providers/fab/src/airflow/providers/fab/www/app.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def create_app(enable_plugins: bool):
9494
init_api_auth(flask_app)
9595

9696
with flask_app.app_context():
97-
init_appbuilder(flask_app, enable_plugins=enable_plugins)
97+
init_appbuilder(flask_app, enable_plugins, db)
9898
init_error_handlers(flask_app)
9999
# In two scenarios a Flask application can be created:
100100
# - To support Airflow 2 plugins relying on Flask (``enable_plugins`` is True)

‎providers/fab/src/airflow/providers/fab/www/extensions/init_appbuilder.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,13 @@ def _process_inner_views(self):
590590
view.get_init_inner_views().append(v)
591591

592592

593-
def init_appbuilder(app: Flask, enable_plugins: bool) -> AirflowAppBuilder:
593+
def init_appbuilder(app: Flask, enable_plugins: bool, db) -> AirflowAppBuilder:
594594
"""Init `Flask App Builder <https://flask-appbuilder.readthedocs.io/en/latest/>`__."""
595595
if settings.Session is None:
596596
raise RuntimeError("Session not configured. Call configure_orm() first.")
597597
return AirflowAppBuilder(
598598
app=app,
599-
session=settings.Session(),
599+
session=db.session,
600600
base_template="airflow/main.html",
601601
enable_plugins=enable_plugins,
602602
)

‎providers/fab/www-hash.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1074f052d6e1b982be7b333efd08d4c28ede680aa3b135504f0e0b519443205f
1+
5fafa901a5841386df6801a90f1b166ed68d6b7b8ac095e840275e5a82d88092

0 commit comments

Comments
 (0)