houqp commented on a change in pull request #7187: [AIRFLOW-6576] fix scheduler 
crash caused by deleted task with sla misses
URL: https://github.com/apache/airflow/pull/7187#discussion_r368085595
 
 

 ##########
 File path: airflow/jobs/scheduler_job.py
 ##########
 @@ -429,7 +429,15 @@ def manage_slas(self, dag, session=None):
             """.format(task_list=task_list, 
blocking_task_list=blocking_task_list,
                        bug=asciiart.bug)
 
-            tasks_missed_sla = [dag.get_task(sla.task_id) for sla in slas]
+            tasks_missed_sla = []
+            for sla in slas:
+                try:
+                    task = dag.get_task(sla.task_id)
+                except AirflowException:
+                    # task already deleted from DAG, skip it
 
 Review comment:
   Yeah, that's the first thing came to my mind, I expected that method to 
throw a more specific exception. I think we should have a clean up PR to change 
that method's behavior.
   
   Ideally, i think it should just return None if the task is not found just 
like a dictionary. Then the caller can explicitly check for the return and 
handle the edge-case. This way, we won't run into issues like this going 
forward.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to