airflow: Airflow users/list/ is very slow

Apache Airflow version

2.6.1

What happened

After upgrading to airflow 2.6 we started seeing slowness while opening users/list/ and roles/list/. It takes around ~1min to open any of these pages.

What you think should happen instead

Ideally these pages shouldn’t take much time to load

How to reproduce

Not sure how to reproduce this 😕

Operating System

Debian GNU/Linux

Versions of Apache Airflow Providers

apache-airflow-providers-amazon==7.1.0 apache-airflow-providers-apache-druid==3.3.1 apache-airflow-providers-apache-hive==5.1.1 apache-airflow-providers-apache-livy==3.2.0 apache-airflow-providers-celery==3.1.0 apache-airflow-providers-cncf-kubernetes==6.1.0 apache-airflow-providers-common-sql==1.4.0 apache-airflow-providers-docker==3.6.0 apache-airflow-providers-elasticsearch==4.3.3 apache-airflow-providers-ftp==3.3.1 apache-airflow-providers-google==10.0.0 apache-airflow-providers-grpc==3.1.0 apache-airflow-providers-hashicorp==3.3.1 apache-airflow-providers-http==4.3.0 apache-airflow-providers-imap==3.1.1 apache-airflow-providers-jdbc==3.3.0 apache-airflow-providers-microsoft-azure==6.0.0 apache-airflow-providers-mongo==3.1.1 apache-airflow-providers-mysql==4.0.2 apache-airflow-providers-neo4j==3.2.1 apache-airflow-providers-odbc==3.2.1 apache-airflow-providers-pagerduty==3.1.0 apache-airflow-providers-papermill==3.1.0 apache-airflow-providers-postgres==5.4.0 apache-airflow-providers-presto==4.2.1 apache-airflow-providers-redis==3.1.0 apache-airflow-providers-sendgrid==3.1.0 apache-airflow-providers-sftp==4.2.4 apache-airflow-providers-slack==7.2.0 apache-airflow-providers-snowflake==4.0.5 apache-airflow-providers-sqlite==3.3.2 apache-airflow-providers-ssh==3.4.0 apache-airflow-providers-tableau==4.0.0 apache-airflow-providers-trino==4.3.1

Deployment

Other Docker-based deployment

Deployment details

We run airflow on AWS ECS.

Anything else

After doing a fresh install of airflow 2.6.1, we noticed this error.

We have around 2-3k dags and 131 custom roles.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 16 (10 by maintainers)

Most upvoted comments

I was checking the overall flow over how flask-appbuilder renders the template. I commented out the search box in the template and the page was faster. I searched for “slow” in the repo and found this issue. Then related fields were created/changed and roles that listed other users/roles from DB. So I tried removing the columns in code and then found that search_exclude_columns is exposed through which it can be configured.

Related issue for search column : https://github.com/dpgaspar/Flask-AppBuilder/issues/796 https://github.com/dpgaspar/Flask-AppBuilder/issues/875

@ayush-san Please try this patch. The performance issue is due to search box. It seems for the fields created_by, changed_by, created and changed there is a DB lookup that happens to fill the search widget with all the roles and users for each field. Keeping in only roles improves performance substantially for us which we use.

Thanks for raising the issue.

diff --git a/airflow/www/fab_security/views.py b/airflow/www/fab_security/views.py
index 24e09e72f7..a79477dc27 100644
--- a/airflow/www/fab_security/views.py
+++ b/airflow/www/fab_security/views.py
@@ -192,6 +192,8 @@ class MultiResourceUserMixin:
         "delete": "delete",
     }
 
+    search_exclude_columns = ["created_by", "updated_by", "created", "changed", "password"]
+
     base_permissions = [
         permissions.ACTION_CAN_READ,
         permissions.ACTION_CAN_EDIT,