Control Airflow task execution with trigger_rule
Use Apache Airflow trigger_rule to run downstream tasks when upstream tasks fail, are skipped, or finish in any state.
30 Jan 2026, 22:26 UTC

The problem: downstream tasks skip when upstream fails
By default, an Airflow task runs only if every direct upstream task succeeds. If one upstream task fails or is skipped, Airflow marks the downstream task as skipped and never executes its logic. This default behavior is safe for linear pipelines, but it breaks patterns such as cleanup, alerting, or fallback processing that must run regardless of upstream outcomes.
Useful takeaway: set the trigger_rule parameter on a downstream task to control exactly which upstream states allow it to run.
How trigger_rule gates execution
trigger_rule is evaluated by the scheduler before a task instance starts. It inspects the states of the task's direct upstream dependencies and decides whether the task should run, be skipped, or be marked as failed. It does not change what the task does, how retries behave, or the DAG's dependency graph.
Common trigger rules
| Rule | When the task runs |
|---|---|
all_success (default) | Only when every direct upstream task succeeded. |
all_done | Once all direct upstreams have reached a terminal state, regardless of success or failure. |
one_success | If at least one direct upstream task succeeded. |
one_failed | If at least one direct upstream task failed. |
Worked configuration: cleanup task that always runs
Suppose a DAG extracts data, loads it, and then removes temporary files. The cleanup task should run whether the load succeeds or fails.
from airflow import DAG
from airflow.operators.bash import BashOperator
from airflow.utils.dates import days_ago
with DAG(
dag_id="etl_with_cleanup",
start_date=days_ago(1),
schedule_interval=None,
catchup=False,
) as dag:
extract = BashOperator(
task_id="extract",
bash_command="echo extracting",
)
load = BashOperator(
task_id="load",
bash_command="echo loading && exit 1",
)
cleanup = BashOperator(
task_id="cleanup",
bash_command="rm -rf /tmp/staging/*",
trigger_rule="all_done",
)
extract >> load >> cleanup
Here load exits with code 1, so it fails. With the default rule, cleanup would be skipped because its upstream load did not succeed. With trigger_rule="all_done", Airflow runs cleanup after load reaches a terminal state.
Where to run and verify
Edit the DAG file on the Airflow host or in the DAGs folder mounted by the scheduler and webserver. Then run a single execution without scheduling:
airflow dags test etl_with_cleanup 2023-01-01
Run this command on the Airflow scheduler host or any machine with the Airflow CLI installed and access to the DAGs folder. The user needs read access to the DAG file and write access to the metadata database or task log location, depending on executor configuration.
Expected check: open the Airflow UI, open the DAG run for 2023-01-01, and confirm cleanup shows success while load shows failed. Task logs should indicate the trigger rule allowed execution despite the upstream failure.
Risk: do not run this against a production metadata database with a future execution date unless you intend to create a backfill record. airflow dags test writes task instances to the database.
Limits of trigger_rule
- It only gates execution. It does not change the task's bash command, Python callable, retries, or
depends_on_pastbehavior. - It applies to direct upstream tasks. A task with no upstream dependencies sees no practical effect from
trigger_rule. - It does not create a new dependency chain. If
cleanupis downstream ofloadonly,extractdoes not influencecleanup's trigger evaluation.
Common mistakes
- Forgetting the rule. Engineers assume a downstream notification task will run after a failure. It stays skipped unless
trigger_ruleis set toone_failedorall_done. - Using one_failed without compensation logic. A task that runs when any upstream fails may itself fail if it assumes successful upstream outputs.
- Applying it to a root task. A task with no upstreams ignores the rule for practical purposes, which confuses other engineers reading the DAG.
Version note
The interaction between trigger_rule and depends_on_past changed in Airflow 2.3+. Verify this behavior on your specific Airflow version before relying on both settings together.
Practical verification
- Set an upstream task to
failedmanually in the Airflow UI or through the metadata database. - Clear the downstream task or trigger a new DAG run.
- Check the Graph view: the downstream task should run only if its configured rule matches the upstream states.
- Inspect the task log for trigger-rule evaluation messages.
If the task skips when you expected it to run, compare the upstream task's final state against the rule. all_done requires all upstreams to reach a terminal state; one_success requires at least one success, not merely completion.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.