apache / airflow

Apache Airflow - A platform to programmatically author, schedule, and monitor workflows
https://airflow.apache.org/
Apache License 2.0
37.04k stars 14.28k forks source link

Failure on editing a Variable #39581

Closed muhzub closed 5 months ago

muhzub commented 6 months ago

Apache Airflow version

Other Airflow 2 version (please specify below)

If "Other Airflow 2 version" selected, which one?

2.8.1

What happened?

I am encountering a problem when sometime on clicking the variable search/edit button it open a critical Error page "Ooops" and the error i can get in webserver logs "sqlalchemy.exc.PendingRollbackError: Can't reconnect until invalid transaction is rolled back. (Background on this error at: https://sqlalche.me/e/14/8s2b)" complete logs are mentioned below

I am not able to see any lock transaction in database and unable to find the reason for this behaviour.

[2024-05-13T03:45:48.832+0000] {app.py:1744} ERROR - Exception on /variable/edit/57 [GET] Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2529, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1825, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "/usr/local/lib/python3.9/site-packages/airflow/www/decorators.py", line 132, in wrapper return f(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/airflow/www/auth.py", line 110, in wraps if permission_str in self.base_permissions and self.appbuilder.sm.has_access( File "/usr/local/lib/python3.9/site-packages/astronomer/flask_appbuilder/security.py", line 301, in has_access return super().has_access(action_name, resource_name, *args, **kwargs) File "/usr/local/lib/python3.9/site-packages/airflow/www/security_manager.py", line 140, in has_access return is_authorized_method(action_name, resource_pk, user) File "/usr/local/lib/python3.9/site-packages/airflow/www/security_manager.py", line 316, in <lambda> details=VariableDetails(key=get_variable_key(resource_pk)), File "/usr/local/lib/python3.9/site-packages/airflow/www/security_manager.py", line 225, in get_variable_key variable = session.scalar(select(Variable).where(Variable.id == resource_pk).limit(1)) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1747, in scalar return self.execute( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1717, in execute result = conn._execute_20(statement, params or {}, execution_options) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1710, in _execute_20 return meth(self, args_10style, kwargs_10style, execution_options) File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/elements.py", line 334, in _execute_on_connection return connection._execute_clauseelement( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1577, in _execute_clauseelement ret = self._execute_context( File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1808, in _execute_context conn = self._revalidate_connection() File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 650, in _revalidate_connection self._invalid_transaction() File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 622, in _invalid_transaction raise exc.PendingRollbackError( sqlalchemy.exc.PendingRollbackError: Can't reconnect until invalid transaction is rolled back. (Background on this error at: https://sqlalche.me/e/14/8s2b)

What you think should happen instead?

it should allow to either view and edit the variable

How to reproduce

I am not sure as this happen sometime but not very frequent

Operating System

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian

Versions of Apache Airflow Providers

apache-airflow-providers-apache-hdfs==3.2.1 apache-airflow-providers-apache-hive apache-airflow-providers-apache-spark apache-airflow-providers-jdbc apache-airflow-providers-sftp apache-airflow-providers-ssh apache-airflow-providers-hashicorp

Deployment

Docker-Compose

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

Code of Conduct

boring-cyborg[bot] commented 6 months ago

Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

raphaelauv commented 6 months ago

I also seen this bug before 2.9.1 with LDAP

amoghrajesh commented 5 months ago

I have seen this kind of issue for connection edit once in the past, and then it never happened

alejandro-rivera commented 5 months ago

I've been experiencing a problem like the one described here, after upgrading to Airflow 2.9.1.

I've pushed a PR with a potential fix: https://github.com/apache/airflow/pull/39935.

Cheers.

UnightSun commented 5 months ago

I've been experiencing a problem like the one described here, after upgrading to Airflow 2.9.1.

I've pushed a PR with a potential fix: #39935.

Cheers.

This works for me, thanks.