nguyenmphu commented on issue #10790: URL: https://github.com/apache/airflow/issues/10790#issuecomment-949189802
I found that in the code of `airflow/jobs/scheduler_job.py`: https://github.com/apache/airflow/blob/main/airflow/jobs/scheduler_job.py#L535 ``` python if ti.try_number == buffer_key.try_number and ti.state == State.QUEUED: Stats.incr('scheduler.tasks.killed_externally') msg = ( "Executor reports task instance %s finished (%s) although the " "task says its %s. (Info: %s) Was the task killed externally?" ) self.log.error(msg, ti, state, ti.state, info) ``` The scheduler checks the state of the task instance. When a task instance is rescheduled (e.g: an external sensor), its state transition up_for_reschedule -> scheduled -> queued -> running. If its state is queued and not moved to the running state, the scheduler will raise an error. So I think the code needs to change: ``` python if ti.try_number == buffer_key.try_number and ( ti.state == State.QUEUED and not TaskReschedule.find_for_task_instance(ti, session=session) ): Stats.incr('scheduler.tasks.killed_externally') msg = ( "Executor reports task instance %s finished (%s) although the " "task says its %s. (Info: %s) Was the task killed externally?" ) self.log.error(msg, ti, state, ti.state, info) ``` Here is my PR: https://github.com/apache/airflow/pull/19123 -- 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]
