Skip to content

Commit

Permalink
Double-check TaskInstance state if it differs from Executor.
Browse files Browse the repository at this point in the history
  • Loading branch information
antonysouthworth-halter committed Oct 16, 2024
1 parent 2425ee0 commit 543afb2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions airflow/jobs/backfill_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ 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(f"In-memory TaskInstance state {ti} does not agree with executor state {state}. Attempting to resolve by refreshing in-memory task instance from DB.")
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 543afb2

Please sign in to comment.