Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double-check TaskInstance state if it differs from the Executor state. #43063

Merged
merged 10 commits into from
Dec 9, 2024
9 changes: 9 additions & 0 deletions airflow/jobs/backfill_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ 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
Loading