Skip to content

Commit

Permalink
Double-check TaskInstance state if it differs from the Executor state. (
Browse files Browse the repository at this point in the history
#43063)

* Double-check TaskInstance state if it differs from Executor.

* Update airflow/jobs/backfill_job_runner.py

* Update airflow/jobs/backfill_job_runner.py

* Update airflow/jobs/backfill_job_runner.py

* Update airflow/jobs/backfill_job_runner.py

* Update airflow/jobs/backfill_job_runner.py

* Update airflow/jobs/backfill_job_runner.py

---------

Co-authored-by: Utkarsh Sharma <utkarsharma2@gmail.com>
  • Loading branch information
antonysouthworth-halter and utkarsharma2 authored Dec 9, 2024
1 parent 99e713e commit 90d6332
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions airflow/jobs/backfill_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,17 @@ def _manage_executor_state(

self.log.debug("Executor state: %s task %s", state, ti)

if (
state in (TaskInstanceState.FAILED, TaskInstanceState.SUCCESS)
and ti.state in self.STATES_COUNT_AS_RUNNING
):
self.log.debug(
"In-memory TaskInstance state %s does not agree with executor state %s. Attempting to resolve by refreshing in-memory task instance from DB.",
ti,
state,
)
ti.refresh_from_db(session=session)

if (
state in (TaskInstanceState.FAILED, TaskInstanceState.SUCCESS)
and ti.state in self.STATES_COUNT_AS_RUNNING
Expand Down

0 comments on commit 90d6332

Please sign in to comment.