Skip to content

Airflow 3.2 Worker Failures on TaskInstance Finish (HTTP 409 invalid_state) #65708

@DominikBalga

Description

@DominikBalga

Under which category would you file this issue?

Task SDK

Apache Airflow version

3.2.0. & 3.2.1

What happened and how to reproduce it?

Issue Description

The observed behavior starts after upgrading to Airflow 3.2.0 (and persists in 3.2.1) and disappears when downgrading to 3.1.8.

The failure manifests on Celery workers during the post-execution "finish" step (Task SDK / execution API), where the worker attempts to PATCH the TaskInstance state and receives:

  • HTTP 409
  • reason=invalid_state
  • message=TI was not in the running state so it cannot be updated
  • previous_state=success

This results in a worker-side exception (ServerResponseError) and causes the Celery workload to be treated as failed even when the underlying task logic has completed.

  • Airflow version(s) affected: 3.2.0, 3.2.1
  • Airflow version known-good: 3.1.8
  • Executor: CeleryExecutor
  • Deployment: Kubernetes
  • Python: 3.12
  • Database: Postgres

Typical worker log sequence:

  • Worker starts and loads secrets backend
  • Worker begins Task SDK API calls (often with retries)
  • API returns 409 invalid_state with previous_state=success
  • Supervisor raises ServerResponseError and the Celery task fails

Example:

  • Secrets backends loaded for worker ...
  • Starting call to 'airflow.sdk.api.client.Client.request', this is the 1st time calling it.
  • Starting call to ... this is the 2nd time calling it.
  • API server error ... status_code=409 ... previous_state='success'
  • airflow.sdk.api.client.ServerResponseError: Server returned error

Steps to reproduce

The issue appears intermittently; higher concurrency tends to increase the frequency.

Prerequisites

  • Airflow 3.2.0+
  • CeleryExecutor
  • Execution API enabled (Task SDK in use)
  1. Deploy Airflow 3.2.0 or 3.2.1.
  2. Trigger the DAG multiple times (or run multiple manual runs concurrently).
  3. Observe worker logs for ServerResponseError with HTTP 409 invalid_state and previous_state=success.

What you think should happen instead?

Airflow workers should be able to finalise a task idempotently; if the API server has already moved the TaskInstance to a terminal state (e.g. success), the worker’s PATCH /execution/task-instances//state should not return a fatal 409 or fail the task.

Operating System

No response

Deployment

Official Apache Airflow Helm Chart

Apache Airflow Provider(s)

No response

Versions of Apache Airflow Providers

No response

Official Helm Chart version

Not Applicable

Kubernetes Version

No response

Helm Chart configuration

No response

Docker Image customizations

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yetpriority:highHigh priority bug that should be patched quickly but does not require immediate new release

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions