You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/01/25 07:07:33 UTC

[GitHub] [airflow] aprettyloner commented on issue #18894: Migrate from 2.1.4 to 2.2.0

aprettyloner commented on issue #18894:
URL: https://github.com/apache/airflow/issues/18894#issuecomment-1020873112


   > SQL we used from our deployment playbook to clean up these tables
   > 
   > Obviously a disclaimer on running this blindly. Validate its rows you can safely remove first by just executing the CTEs
   > 
   > ```sql
   > BEGIN;
   > 
   > -- Remove dag runs without a valid run_id
   > DELETE FROM dag_run WHERE run_id is NULL;
   > 
   > -- Remove task fails without a run_id
   > WITH task_fails_to_remove AS (
   >   SELECT 
   >     task_fail.dag_id,
   >     task_fail.task_id,
   >     task_fail.execution_date
   >   FROM
   >     task_fail
   >   LEFT JOIN 
   >     dag_run ON 
   >     dag_run.dag_id = task_fail.dag_id 
   >     AND dag_run.execution_date = task_fail.execution_date
   >   WHERE
   >     dag_run.run_id IS NULL
   > )
   > DELETE FROM
   >     task_fail
   > USING 
   >     task_fails_to_remove
   > WHERE (
   >     task_fail.dag_id = task_fails_to_remove.dag_id
   >     AND task_fail.task_id = task_fails_to_remove.task_id
   >     AND task_fail.execution_date = task_fails_to_remove.execution_date
   > );
   > 
   > -- Remove task instances without a run_id
   > WITH task_instances_to_remove AS (
   >   SELECT
   >     task_instance.dag_id,
   >     task_instance.task_id,
   >     task_instance.execution_date
   >   FROM
   >     task_instance
   >   LEFT JOIN 
   >     dag_run 
   >     ON dag_run.dag_id = task_instance.dag_id
   >     AND dag_run.execution_date = task_instance.execution_date
   >   WHERE 
   >     dag_run.run_id is NULL
   > )
   > DELETE FROM 
   >     task_instance
   > USING
   >     task_instances_to_remove
   > WHERE (
   >     task_instance.dag_id = task_instances_to_remove.dag_id
   >     AND task_instance.task_id = task_instances_to_remove.task_id
   >     AND task_instance.execution_date = task_instances_to_remove.execution_date
   > );
   > 
   > COMMIT;
   > ```
   
   Thank you for this @leonsmith ! Made our team's upgrade from v2.1.4 to v2.2.3 very clean and simple! 🚀 🚀 🚀 🚀 


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org