How to delete a DAG run in Apache Airflow?
Asked Answered
R

3

24

I know there is a way to delete a DAG. But is it possible to delete a DAG run with a specific run_id? Something like:

airflow delete_dag_run <dag_id> <run_id>

Roily answered 19/10, 2019 at 1:44 Comment(3)
One way to delete a DAG is to delete the dag file from the dags folderCurare
#40652283Otic
Anyone know how I can restart my accidentally deleted dag runHiga
R
41

To delete a DAG Run from the Airflow UI:

  1. Browse > "DAG Runs".
  2. Select the DAG Runs you want to delete with the checkboxes on the left.
  3. "With selected" > Delete.
Roily answered 22/10, 2019 at 18:34 Comment(1)
I performed these 3 steps. But the deleted run spawned again after about 1 minute..Habit
S
8

You can also delete the "DAG Runs" from airflow database:

DELETE FROM dag_run
WHERE dag_id='my_dag_id' AND 
state='STATE_I_WANT_TO_DELETE'
Sandhog answered 5/10, 2020 at 19:50 Comment(3)
is removing from db enought so airflow won't somehow take this runs out from memory/session whatever and execute?Betteanne
@Betteanne Thats a good question, my experience was airflow seemed to constantly check database so i did not see much delay there. Which makes sense to me because database is the final state of DAGs. And even if I change from airflow console UI I'm sure it will also update the database.Sandhog
Shouldn't the task instances be deleted too?Marriott
C
0

Its better to use CLI to remove the logs details. For example, lets say, we have a dag with dag_id = 'DAG_ID', then to remove its all metadata records i.e., old jobs run details, execute below command via CLI

airflow dags delete 'DAG_ID'

also, to remove all dags meta data at once, execute below command

 airflow db reset
Caddell answered 29/7 at 6:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.