You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ur...@apache.org on 2024/04/11 10:24:12 UTC
(airflow) branch main updated: Fix implicit cartessian product in AirflowSecurityManagerV2 (#38913)
This is an automated email from the ASF dual-hosted git repository.
uranusjr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new e16dc0fc28 Fix implicit cartessian product in AirflowSecurityManagerV2 (#38913)
e16dc0fc28 is described below
commit e16dc0fc2862bfa5e90e7f080f12b36c992972b7
Author: Andrey Anshin <An...@taragol.is>
AuthorDate: Thu Apr 11 14:24:03 2024 +0400
Fix implicit cartessian product in AirflowSecurityManagerV2 (#38913)
Co-authored-by: Tzu-ping Chung <ur...@gmail.com>
---
airflow/www/security_manager.py | 8 ++++----
pyproject.toml | 2 ++
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/airflow/www/security_manager.py b/airflow/www/security_manager.py
index c63de34068..88c2caa32a 100644
--- a/airflow/www/security_manager.py
+++ b/airflow/www/security_manager.py
@@ -199,8 +199,8 @@ class AirflowSecurityManagerV2(LoggingMixin):
if not resource_pk:
return None
composite_pk = json.loads(resource_pk)
- ti = session.scalar(
- select(DagRun)
+ dag_id = session.scalar(
+ select(TaskInstance.dag_id)
.where(
TaskInstance.dag_id == composite_pk[0],
TaskInstance.task_id == composite_pk[1],
@@ -209,9 +209,9 @@ class AirflowSecurityManagerV2(LoggingMixin):
)
.limit(1)
)
- if not ti:
+ if not dag_id:
raise AirflowException("Task instance not found")
- return ti.dag_id
+ return dag_id
def get_pool_name(resource_pk):
if not resource_pk:
diff --git a/pyproject.toml b/pyproject.toml
index 6558373f9f..78476e7ef6 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -464,6 +464,8 @@ norecursedirs = [
log_level = "INFO"
filterwarnings = [
"error::pytest.PytestCollectionWarning",
+ # Avoid building cartesian product which might impact performance
+ "error:SELECT statement has a cartesian product between FROM:sqlalchemy.exc.SAWarning:airflow",
"ignore::DeprecationWarning:flask_appbuilder.filemanager",
"ignore::DeprecationWarning:flask_appbuilder.widgets",
# FAB do not support SQLAclhemy 2