<h3 dir="auto">Apache Airflow version</h3>
<p dir="auto">2.3.2 (latest released)</p>
<h3 dir="auto">What happened</h3>
<p dir="auto">After the update to 2.3.0, the ability to remove dags from the ui, if they had tags, disappeared.</p>
<p dir="auto">With update 2.3.2, the problem should have been solved, but the delete now takes a very long time.</p>
<p dir="auto">When I try to remove the DAG from the interface, I get a 504 Gateway Timeout error, since the request to the database takes a long time.</p>
<p dir="auto">This is repeated with any DAG where there are many runs.</p>
<h3 dir="auto">What you think should happen instead</h3>
<p dir="auto">The DAG execution history should be deleted.</p>
<h3 dir="auto">How to reproduce</h3>
<ol dir="auto">
<li>Run a dag and generate more than 1000 runs.</li>
<li>Remove dag via web ui.</li>
</ol>
<h3 dir="auto">Operating System</h3>
<p dir="auto">Ubuntu 18.04.4 LTS (Bionic Beaver)</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto">apache-airflow-providers-amazon==3.4.0<br>
apache-airflow-providers-celery==2.1.4<br>
apache-airflow-providers-cncf-kubernetes==4.0.2<br>
apache-airflow-providers-docker==2.7.0<br>
apache-airflow-providers-elasticsearch==3.0.3<br>
apache-airflow-providers-ftp==2.1.2<br>
apache-airflow-providers-google==7.0.0<br>
apache-airflow-providers-grpc==2.0.4<br>
apache-airflow-providers-hashicorp==2.2.0<br>
apache-airflow-providers-http==2.1.2<br>
apache-airflow-providers-imap==2.2.3<br>
apache-airflow-providers-jdbc==2.1.3<br>
apache-airflow-providers-microsoft-azure==3.9.0<br>
apache-airflow-providers-microsoft-mssql==2.1.3<br>
apache-airflow-providers-mongo==2.3.3<br>
apache-airflow-providers-mysql==2.2.3<br>
apache-airflow-providers-odbc==2.0.4<br>
apache-airflow-providers-oracle==2.2.3<br>
apache-airflow-providers-postgres==4.1.0<br>
apache-airflow-providers-redis==2.0.4<br>
apache-airflow-providers-samba==3.0.0<br>
apache-airflow-providers-sendgrid==2.0.4<br>
apache-airflow-providers-sftp==2.6.0<br>
apache-airflow-providers-slack==4.2.3<br>
apache-airflow-providers-sqlite==2.1.3<br>
apache-airflow-providers-ssh==2.4.4<br>
apache-airflow-providers-trino==2.3.0</p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Official Apache Airflow Helm Chart</p>
<h3 dir="auto">Deployment details</h3>
<p dir="auto">Kubernetes v1.18.15</p>
<h3 dir="auto">Anything else</h3>
<p dir="auto">I tried to run the analysis of the SQL request to delete the dag manually and got the following result:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="DELETE FROM dag_run WHERE dag_run.dag_id IN ('test') RETURNING dag_run.id"><pre class="notranslate"><code class="notranslate">DELETE FROM dag_run WHERE dag_run.dag_id IN ('test') RETURNING dag_run.id
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Delete on dag_run  (cost=1440.76..32883.24 rows=27398 width=6) (actual time=2169082.358..2169985.242 rows=26750 loops=1)
  -&gt;  Bitmap Heap Scan on dag_run  (cost=1440.76..32883.24 rows=27398 width=6) (actual time=7.132..319.677 rows=26750 loops=1)
        Recheck Cond: ((dag_id)::text = 'test'::text)
        Heap Blocks: exact=6157
        -&gt;  Bitmap Index Scan on dag_id_state  (cost=0.00..1433.91 rows=27398 width=0) (actual time=5.963..5.963 rows=26750 loops=1)
              Index Cond: ((dag_id)::text = 'test'::text)
Planning Time: 0.134 ms
Trigger for constraint task_instance_dag_run_fkey on dag_run: time=1694.339 calls=26750
Trigger for constraint task_reschedule_dr_fkey on dag_run: time=408.320 calls=26750
Trigger for constraint task_reschedule_ti_fkey on task_instance: time=2103.582 calls=53500
Trigger for constraint task_map_task_instance_fkey on task_instance: time=1802.304 calls=53500
Trigger for constraint xcom_task_instance_fkey on task_instance: time=2264561.198 calls=53500
Trigger for constraint rtif_ti_fkey on task_instance: time=5526.311 calls=53500
Trigger for constraint task_fail_ti_fkey on task_instance: time=3081.837 calls=53500
Execution Time: 4449310.647 ms"><pre class="notranslate"><code class="notranslate">Delete on dag_run  (cost=1440.76..32883.24 rows=27398 width=6) (actual time=2169082.358..2169985.242 rows=26750 loops=1)
  -&gt;  Bitmap Heap Scan on dag_run  (cost=1440.76..32883.24 rows=27398 width=6) (actual time=7.132..319.677 rows=26750 loops=1)
        Recheck Cond: ((dag_id)::text = 'test'::text)
        Heap Blocks: exact=6157
        -&gt;  Bitmap Index Scan on dag_id_state  (cost=0.00..1433.91 rows=27398 width=0) (actual time=5.963..5.963 rows=26750 loops=1)
              Index Cond: ((dag_id)::text = 'test'::text)
Planning Time: 0.134 ms
Trigger for constraint task_instance_dag_run_fkey on dag_run: time=1694.339 calls=26750
Trigger for constraint task_reschedule_dr_fkey on dag_run: time=408.320 calls=26750
Trigger for constraint task_reschedule_ti_fkey on task_instance: time=2103.582 calls=53500
Trigger for constraint task_map_task_instance_fkey on task_instance: time=1802.304 calls=53500
Trigger for constraint xcom_task_instance_fkey on task_instance: time=2264561.198 calls=53500
Trigger for constraint rtif_ti_fkey on task_instance: time=5526.311 calls=53500
Trigger for constraint task_fail_ti_fkey on task_instance: time=3081.837 calls=53500
Execution Time: 4449310.647 ms
</code></pre></div>
<p dir="auto">It runs for a very long time, it is unrealistic to increase the worker timeout to such a value.</p>
<h3 dir="auto">Are you willing to submit PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Yes I am willing to submit a PR!</li>
</ul>
<h3 dir="auto">Code of Conduct</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow this project's <a href="https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>
<h3 dir="auto">Apache Airflow version</h3>
<p dir="auto">2.1.2</p>
<h3 dir="auto">What happened</h3>
<p dir="auto">We had restarted Airflow scheduler. After restart, we suddenly saw all our DAG's were missing from the UI. When we go to old tasks from task_instaces page &amp; look at the old task it says this error.</p>
<p dir="auto">Something bad has happened.<br>
Please consider letting us know by creating a bug report using GitHub.</p>
<h2 dir="auto">Python version: 3.8.11<br>
Airflow version: 2.1.2<br>
Node: airflow-web-77b556776d-wrmt9</h2>
<p dir="auto">Traceback (most recent call last):<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app<br>
response = self.full_dispatch_request()<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request<br>
rv = self.handle_user_exception(e)<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception<br>
reraise(exc_type, exc_value, tb)<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise<br>
raise value<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request<br>
rv = self.dispatch_request()<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request<br>
return self.view_functions<a href="**req.view_args">rule.endpoint</a><br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/www/auth.py", line 34, in decorated<br>
return func(*args, **kwargs)<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/www/decorators.py", line 97, in view_func<br>
return f(*args, **kwargs)<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/www/decorators.py", line 60, in wrapper<br>
return f(*args, **kwargs)<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/utils/session.py", line 70, in wrapper<br>
return func(*args, session=session, **kwargs)<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/www/views.py", line 2156, in graph<br>
dag = current_app.dag_bag.get_dag(dag_id)<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/utils/session.py", line 70, in wrapper<br>
return func(*args, session=session, **kwargs)<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/models/dagbag.py", line 186, in get_dag<br>
self._add_dag_from_db(dag_id=dag_id, session=session)<br>
File "/opt/bitnami/airflow/venv/lib/python3.8/site-packages/airflow/models/dagbag.py", line 258, in _add_dag_from_db<br>
raise SerializedDagNotFound(f"DAG '{dag_id}' not found in serialized_dag table")<br>
airflow.exceptions.SerializedDagNotFound: DAG 'DAP_dbricks_user_creation' not found in serialized_dag table</p>
<p dir="auto"><em>What have we noticed is is_active column for all DAG's in public.dag table is set to 'false' and public.serialized_dag table is empty.</em></p>
<p dir="auto">We tried to restore these 2 tables &amp; after restoration in 1-2 mins inserted records is getting deleted from serialized_dag &amp; it is getting updated back to false in dag table.</p>
<p dir="auto">We also don't find .py files regarding DAG's in /opt/bitnami/airflow/dags/git_airflow-dags/ path.</p>
<h3 dir="auto">What you expected to happen</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">Ubuntu (AKS)</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Official Apache Airflow Helm Chart</p>
<h3 dir="auto">Deployment details</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Anything else</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Are you willing to submit PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Yes I am willing to submit a PR!</li>
</ul>
<h3 dir="auto">Code of Conduct</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow this project's <a href="https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>