canyang25 commented on code in PR #74212:
URL: https://github.com/apache/airflow/pull/74212#discussion_r4747339625


##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -1622,11 +1643,17 @@ def process_executor_events(
                 ti.queued_by_job_id != job_id  # Another scheduler has queued 
this task again
                 or executor.has_task(ti)  # This scheduler has this task 
already
                 or (
-                    # Resume-after-defer: trigger moved TI to scheduled or 
queued (next_method set)
-                    # before we saw the executor success from the defer exit 
for the same try_number.
                     ti.state in (TaskInstanceState.SCHEDULED, 
TaskInstanceState.QUEUED)
                     and state == TaskInstanceState.SUCCESS
-                    and ti.next_method is not None
+                    and (
+                        # Resume-after-defer: trigger moved TI to scheduled or 
queued (next_method set)
+                        # before we saw the executor success from the defer 
exit for the same try_number.
+                        ti.next_method is not None
+                        # Sensor in reschedule mode: the TI was put back for 
its next poke before we saw
+                        # the executor success from the previous poke. That 
exit leaves next_method unset,
+                        # so an existing task_reschedule row is what separates 
it from an external kill.
+                        or ti.id in rescheduled_ti_ids

Review Comment:
   test_process_executor_events_failed_with_reschedule_row_still_fails covers a 
scheduled or queued task instance that already has a task_reschedule row when 
the executor reports FAILED. The task is marked failed through handle_failure, 
and scheduler.tasks.killed_externally is still recorded, so the reschedule row 
does not suppress a real failure.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to