10. Each Day Waits for Yesterday
Difficulty: Hard · Topic: Ordering & concurrency
The DAG running_balance keeps a running total, so each day builds on the day before. It runs @daily from 2026-03-01 to 2026-03-05 with catchup=True, and has two BashOperator tasks:
pull_entries(pull_entries --date {{ ds }}) reads yesterday's balance.update_balance(update_balance --date {{ ds }}) runs after it and writes today's balance.
The rules:
- A day's
pull_entriesmust not start until the previous day'supdate_balancehas succeeded, or it would read a stale balance. - If a day fails for good, no later day may run at all.
- The scheduler may keep several runs active. Do not limit runs with
max_active_runs: it would not stop the later days after a failure.
update_balance has retries=1 and retry_delay=timedelta(minutes=5).
Your DAG file is run in a simulation of the Airflow 3 scheduler against 4 scenarios, including hidden ones.
Sample scenario: Five clean days
Deployed 2026-03-10 00:30 UTC, read at 2026-03-10 02:00 UTC.
Expected runs
- Run at 2026-03-01 00:00 UTC: success. pull_entries success, update_balance success
- Run at 2026-03-02 00:00 UTC: success. pull_entries success, update_balance success
- Run at 2026-03-03 00:00 UTC: success. pull_entries success, update_balance success
- Run at 2026-03-04 00:00 UTC: success. pull_entries success, update_balance success
- Run at 2026-03-05 00:00 UTC: success. pull_entries success, update_balance success
Hints
Hint 1
depends_on_past=True makes a task wait for the same task in the previous run, and only that task.Hint 2
wait_for_downstream=True also waits for the tasks directly downstream of it in the previous run. It turns on depends_on_past for that task.Hint 3
A held-back task stays with no state, and its run stays running. Nothing fails or gets skipped.Learn the concepts
- Catchup, backfill and end_date · 5 min read. Which runs a late deploy creates, filling history on purpose, and limiting runs in flight.
- Idempotent pipelines with Spark and Delta · 5 min read. Jobs that a retry, rerun or backfill cannot corrupt, and chains of days that stop at a failure.
More Airflow problems
- One Export at a Time · Medium