buhuipao commented on a change in pull request #8259: [AIRFLOW-XXX] Optimize 
airflow scheduler
URL: https://github.com/apache/airflow/pull/8259#discussion_r410665197
 
 

 ##########
 File path: airflow/jobs.py
 ##########
 @@ -1644,26 +1738,31 @@ def _execute_helper(self, processor_manager):
                 # If a task instance is up for retry but the corresponding DAG 
run
                 # isn't running, mark the task instance as FAILED so we don't 
try
                 # to re-run it.
-                self._change_state_for_tis_without_dagrun(simple_dag_bag,
-                                                          [State.UP_FOR_RETRY],
-                                                          State.FAILED)
+                ret = self._change_state_for_tis_without_dagrun(simple_dag_bag,
+                                                                
[State.UP_FOR_RETRY],
+                                                                State.FAILED)
+                if not ret:
+                    continue
                 # If a task instance is scheduled or queued, but the 
corresponding
                 # DAG run isn't running, set the state to NONE so we don't try 
to
                 # re-run it.
-                self._change_state_for_tis_without_dagrun(simple_dag_bag,
-                                                          [State.QUEUED,
-                                                           State.SCHEDULED],
-                                                          State.NONE)
-
+                ret = self._change_state_for_tis_without_dagrun(simple_dag_bag,
+                                                                [State.QUEUED,
+                                                                 
State.SCHEDULED],
+                                                                State.NONE)
+                if not ret:
+                    continue
                 self._execute_task_instances(simple_dag_bag,
                                              (State.SCHEDULED,))
 
             # Call heartbeats
             self.log.info("Heartbeating the executor")
             self.executor.heartbeat()
 
-            # Process events from the executor
-            self._process_executor_events(simple_dag_bag)
+            # Process all events from the executor
+            full_simple_dag_bag = SimpleDagBag(self.full_simple_dags.values())
+            self.executor_events = 
self._process_executor_events(full_simple_dag_bag)
 
 Review comment:
   Thank for your advice,I will push right code to the master branch in next 
time.

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