Gaurang033 opened a new issue #11134: URL: https://github.com/apache/airflow/issues/11134
<!-- Welcome to Apache Airflow! For a smooth issue process, try to answer the following questions. Don't worry if they're not all applicable; just try to include what you can :-) If you need to include code snippets or logs, please put them in fenced code blocks. If they're super-long, please use the details tag like <details><summary>super-long log</summary> lots of stuff </details> Please delete these comment blocks before submitting the issue. --> <!-- IMPORTANT!!! PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE NEXT TO "SUBMIT NEW ISSUE" BUTTON!!! PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!! Please complete the next sections or the issue will be closed. These questions are the first thing we need to know to understand the context. --> **Apache Airflow version**: 1.10.10 **Kubernetes version (if you are using kubernetes)** (use `kubectl version`): **Environment**: prod - **Cloud provider or hardware configuration**: aws - **OS** (e.g. from /etc/os-release): NAME="Amazon Linux AMI" VERSION="2018.03" ID="amzn" ID_LIKE="rhel fedora" VERSION_ID="2018.03" PRETTY_NAME="Amazon Linux AMI 2018.03" ANSI_COLOR="0;33" CPE_NAME="cpe:/o:amazon:linux:2018.03:ga" HOME_URL="http://aws.amazon.com/amazon-linux-ami/" - **Kernel** (e.g. `uname -a`): Linux ip-10-160-1-11 4.14.154-99.181.amzn1.x86_64 #1 SMP Sat Nov 16 01:38:34 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux - **Install tools**: - **Others**: **What happened**: While deleting example dags from UI, I am getting following error. I think the foreign key contstain for **dag_tag** table has not been handled properly. If I modify the dag and remove tags, I am successfully able to remove the DAG. <!-- (please include exact error messages if you can) --> **What you expected to happen**: Delete dag without any error. <!-- What do you think went wrong? --> Traceback (most recent call last): File "/usr/local/lib64/python2.7/site-packages/flask/app.py", line 2447, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib64/python2.7/site-packages/flask/app.py", line 1952, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib64/python2.7/site-packages/flask/app.py", line 1821, in handle_user_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib64/python2.7/site-packages/flask/app.py", line 1950, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib64/python2.7/site-packages/flask/app.py", line 1936, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/local/lib/python2.7/site-packages/airflow/www_rbac/decorators.py", line 121, in wrapper return f(self, *args, **kwargs) File "/usr/local/lib/python2.7/site-packages/flask_appbuilder/security/decorators.py", line 101, in wraps return f(self, *args, **kwargs) File "/usr/local/lib/python2.7/site-packages/airflow/www_rbac/decorators.py", line 56, in wrapper return f(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/airflow/www_rbac/views.py", line 972, in delete delete_dag.delete_dag(dag_id) File "/usr/local/lib/python2.7/site-packages/airflow/utils/db.py", line 74, in wrapper return func(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/airflow/api/common/experimental/delete_dag.py", line 61, in delete_dag count += session.query(model).filter(cond).delete(synchronize_session='fetch') File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 3789, in delete delete_op.exec_() File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1697, in exec_ self._do_exec() File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1928, in _do_exec self._execute_stmt(delete_stmt) File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 1702, in _execute_stmt self.result = self.query._execute_crud(stmt, self.mapper) File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/orm/query.py", line 3436, in _execute_crud return conn.execute(stmt, self._params) File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 984, in execute return meth(self, multiparams, params) File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/sql/elements.py", line 293, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1103, in _execute_clauseelement distilled_params, File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1288, in _execute_context e, statement, parameters, cursor, context File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1482, in _handle_dbapi_exception sqlalchemy_exception, with_traceback=exc_info[2], from_=e File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context cursor, statement, parameters, context File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute cursor.execute(statement, parameters) 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)=(example_pig_operator) is still referenced from table "dag_tag". [SQL: DELETE FROM dag WHERE dag.dag_id = %(dag_id_1)s OR dag.dag_id LIKE %(dag_id_2)s] [parameters: {'dag_id_1': u'example_pig_operator', 'dag_id_2': u'example_pig_operator.%'}] (Background on this error at: http://sqlalche.me/e/gkpj) **How to reproduce it**: - Login to UI - click on delete button for any DAG <!--- As minimally and precisely as possible. Keep in mind we do not have access to your cluster or dags. If you are using kubernetes, please attempt to recreate the issue using minikube or kind. ## Install minikube/kind - Minikube https://minikube.sigs.k8s.io/docs/start/ - Kind https://kind.sigs.k8s.io/docs/user/quick-start/ If this is a UI bug, please provide a screenshot of the bug or a link to a youtube video of the bug in action You can include images using the .md style of  To record a screencast, mac users can use QuickTime and then create an unlisted youtube video with the resulting .mov file. ---> **Anything else we need to know**: N/A <!-- How often does this problem occur? Once? Every time etc? Any relevant logs to include? Put them here in side a detail tag: <details><summary>x.log</summary> lots of stuff </details> --> ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
