Airflow Task Lifecycle
Every task passes through a series of states from the moment it is created until it finishes. Airflow records each state in the metadata database and shows it as a color in the UI. Reading these states tells you exactly where a task is stuck and why.
The Parcel Tracking Picture
Think of a parcel you order online. It moves through states such as "order placed", "packed", "on the truck", "delivered", or "delivery failed, retry tomorrow". A task follows the same kind of journey.
Parcel Task ────────────────────────────────────── Order placed → none Order confirmed → scheduled Waiting at warehouse → queued On the truck → running Delivered → success Delivery failed → failed Reattempt tomorrow → up_for_retry
The Normal Journey
none ──► scheduled ──► queued ──► running ──► success
│
├──► failed
│
└──► up_for_retry ──► scheduled ...
All Task States
| State | Meaning |
|---|---|
| none | Task exists but the scheduler has not looked at it |
| scheduled | Scheduler decided the task should run |
| queued | Executor holds the task and waits for a free worker |
| running | A worker executes the task code |
| success | Task finished without errors |
| failed | Task raised an error and has no retries left |
| up_for_retry | Task failed and will try again after a delay |
| up_for_reschedule | A sensor released its worker and will check again later |
| deferred | Task waits for the triggerer to report an event |
| skipped | Task was bypassed, often by a branch |
| upstream_failed | A task before it failed, so this one cannot run |
| removed | Task disappeared from the DAG after the run began |
Stage by Stage
Scheduled and Queued
A task becomes scheduled when its parents succeed and the run is due. The scheduler then passes it to the executor, and the state changes to queued. A task stays queued when every worker slot is busy. Long queued times point to a capacity problem.
Running
A worker starts a process and runs your code. Airflow writes a heartbeat to the database every few seconds. A missing heartbeat tells Airflow that the process died.
Success and Failed
A clean finish ends in success. An uncaught error ends in failed or up_for_retry, depending on the retry settings.
Retry Cycle
from datetime import timedelta
task = PythonOperator(
task_id="load_data",
python_callable=load_data,
retries=3,
retry_delay=timedelta(minutes=5),
)
With these settings, a failed task waits five minutes and tries again, up to three times. Each attempt appears as a separate log in the UI.
States That Surprise Beginners
Skipped
Skipped does not mean broken. Branching tasks skip the paths they did not choose. The color is pink in the UI.
Upstream Failed
One failure creates a chain of upstream_failed tasks. Fix the first red task, since the orange ones only reflect that problem.
extract ──► transform ──► load
FAILED upstream_ upstream_
failed failed
▲
└── fix this one first
Clearing a Task
Clearing resets a task to none so that Airflow runs it again. Use the Clear button in the Grid view after you fix the cause of a failure. Pick the option that also clears downstream tasks when later steps need fresh results.
Task State Cheat Sheet
- Stuck in scheduled: check that the scheduler runs and the DAG is unpaused.
- Stuck in queued: add worker capacity or raise slot limits.
- Stuck in running: open the logs and look for a slow query or a hung request.
- Repeated up_for_retry: read the first attempt's log for the real error.
Key Takeaways
- A task moves through scheduled, queued, running, and a final state.
- Colors in the UI map directly to these states.
- Retries create extra attempts without creating extra tasks.
- Reading the state narrows down the cause of almost any problem.
