TamGB opened a new issue, #24465:
URL: https://github.com/apache/airflow/issues/24465

   ### Apache Airflow version
   
   2.3.1
   
   ### What happened
   
   When attempting to delete a DAG using Airflow 2.3.1 I get the following 
error, and the DAG along with its metadata are effectively not deleted:
   
   ```
   Something bad has happened.
   
   Airflow is used by many users, and it is very likely that others had similar 
problems and you can easily find
   a solution to your problem.
   
   Consider following these steps:
   
     * gather the relevant information (detailed logs with errors, reproduction 
steps, details of your deployment)
   
     * find similar issues using:
        * [GitHub Discussions](https://github.com/apache/airflow/discussions)
        * [GitHub Issues](https://github.com/apache/airflow/issues)
        * [Stack Overflow](https://stackoverflow.com/questions/tagged/airflow)
        * the usual search engine you use on a daily basis
   
     * if you run Airflow on a Managed Service, consider opening an issue using 
the service support channels
   
     * if you tried and have difficulty with diagnosing and fixing the problem 
yourself, consider creating a [bug 
report](https://github.com/apache/airflow/issues/new/choose).
       Make sure however, to include all relevant details and results of your 
investigation so far.
   
   Python version: 3.7.13
   Airflow version: 2.3.1
   Node: airflow-webserver-766ff4b954-p7m8m
   
-------------------------------------------------------------------------------
   Traceback (most recent call last):
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", 
line 1706, in _execute_context
       cursor, statement, parameters, context
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/engine/default.py",
 line 716, in do_execute
       cursor.execute(statement, parameters)
   psycopg2.errors.ForeignKeyViolation: update or delete on table "dag" 
violates foreign key constraint "dag_tag_dag_id_fkey" on table "dag_tag"
   DETAIL:  Key (dag_id)=(etl_daily_stg) is still referenced from table 
"dag_tag".
   
   
   The above exception was the direct cause of the following exception:
   
   Traceback (most recent call last):
     File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 
2447, in wsgi_app
       response = self.full_dispatch_request()
     File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 
1952, in full_dispatch_request
       rv = self.handle_user_exception(e)
     File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 
1821, in handle_user_exception
       reraise(exc_type, exc_value, tb)
     File "/home/airflow/.local/lib/python3.7/site-packages/flask/_compat.py", 
line 39, in reraise
       raise value
     File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 
1950, in full_dispatch_request
       rv = self.dispatch_request()
     File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 
1936, in dispatch_request
       return self.view_functions[rule.endpoint](**req.view_args)
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/www/auth.py", line 
43, in decorated
       return func(*args, **kwargs)
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/www/decorators.py", 
line 80, in wrapper
       return f(*args, **kwargs)
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/www/views.py", line 
1844, in delete
       delete_dag.delete_dag(dag_id)
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/utils/session.py", 
line 71, in wrapper
       return func(*args, session=session, **kwargs)
     File 
"/home/airflow/.local/lib/python3.7/site-packages/airflow/api/common/delete_dag.py",
 line 80, in delete_dag
       .delete(synchronize_session='fetch')
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/orm/query.py", 
line 3111, in delete
       execution_options={"synchronize_session": synchronize_session},
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", 
line 1670, in execute
       result = conn._execute_20(statement, params or {}, execution_options)
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", 
line 1520, in _execute_20
       return meth(self, args_10style, kwargs_10style, execution_options)
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", 
line 314, in _execute_on_connection
       self, multiparams, params, execution_options
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", 
line 1399, in _execute_clauseelement
       cache_hit=cache_hit,
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", 
line 1749, in _execute_context
       e, statement, parameters, cursor, context
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", 
line 1930, in _handle_dbapi_exception
       sqlalchemy_exception, with_traceback=exc_info[2], from_=e
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", 
line 211, in raise_
       raise exception
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", 
line 1706, in _execute_context
       cursor, statement, parameters, context
     File 
"/home/airflow/.local/lib/python3.7/site-packages/sqlalchemy/engine/default.py",
 line 716, in do_execute
       cursor.execute(statement, parameters)
   sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) update 
or delete on table "dag" violates foreign key constraint "dag_tag_dag_id_fkey" 
on table "dag_tag"
   DETAIL:  Key (dag_id)=(etl_daily_stg) is still referenced from table 
"dag_tag".
   
   [SQL: DELETE FROM dag WHERE dag.dag_id IN (%(dag_id_1_1)s) RETURNING 
dag.dag_id]
   [parameters: {'dag_id_1_1': 'etl_daily_stg'}]
   (Background on this error at: http://sqlalche.me/e/14/gkpj)
   ```
   
   ### What you think should happen instead
   
   DAG should be deleted along with the associated metadata
   
   ### How to reproduce
   
   _No response_
   
   ### Operating System
   
   UNIX
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   _No response_
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to