Airflow Backfill Strategy That Does Not Take the Warehouse Down

A backfill is the one routine Airflow operation that can hurt a system you do not own. It is a scheduled burst of work against your warehouse, your source APIs and your own metadata database, usually started by someone who is also fixing an incident. This note covers how to plan one so it does not take the warehouse down. It assumes Airflow 3.x, and it flags where Airflow 2 behaves differently.

What changed in Airflow 3

In Airflow 2 the airflow dags backfill CLI ran its own loop in the CLI process. It bypassed some scheduler logic, and it died if your shell session did. In Airflow 3 backfills are created through the scheduler, via the UI, the REST API or airflow backfill create. They are ordinary DAG runs with a backfill record attached, so they respect max_active_runs, pools and the executor like everything else. Check the options your installed version supports with airflow backfill create --help before you script anything.

Two further defaults matter. catchup is off by default in Airflow 3, so a DAG that was silently catching up on 2.x may stop doing so after the upgrade. Decide that on purpose rather than finding out from a gap in the data.

Caveat: if you are still on Airflow 2, the old CLI path is what you have. The advice below on limiting concurrency still applies, but the mechanism differs.

Step 1: Decide whether you need a backfill at all

Ask three questions first.

  • Is the task idempotent for a past interval? If it appends rows without a delete-or-merge on the interval key, a rerun duplicates data. Fix that first.
  • Does the task read "now" or the interval? Code that calls datetime.now() or reads a "latest" table will produce different output for a past date. Backfilling it gives you wrong data, not old data.
  • Does the source still hold the history? Many APIs and log buckets expire data. A backfill that succeeds on empty input is worse than one that fails.

If the answer to any is no, the right move is often a one-off SQL repair, not a backfill.

Step 2: Bound the blast radius

Set limits before you create the run, not after you see load.

  • max_active_runs on the DAG. For a backfill of 90 daily intervals, this is the main control. Start at 1 or 2.
  • A dedicated pool for the heavy tasks, sized to what the warehouse tolerates. A pool of 4 slots on a warehouse queue means at most four concurrent loads across the whole estate, backfill or not. Note that pool slots are shared with the nightly batch. If you do not want the backfill to compete, create a separate pool and assign the backfill's tasks to it, or run it in a quiet window.
  • max_active_tis_per_dag and max_active_tis_per_dagrun on the expensive tasks.
  • Priority weights. Give the nightly run a higher priority_weight than backfill tasks so a backfill cannot starve production. This only works inside a pool; it does nothing if tasks are not contending for slots.

A simple pool for this purpose:

airflow pools set warehouse_backfill 3 "Backfill load against warehouse"

Caveat: the pool is applied per task definition, not per run. You cannot say "these runs use this pool" without changing the DAG file, so for a one-time backfill, consider a short-lived DAG change reviewed like any other.

Step 3: Dry run the interval list

Before executing, list exactly which logical dates will run. Both the UI and the CLI have a dry-run option for backfills in current 3.x releases. Read the list. The common errors are an off-by-one at the end date, a timezone mismatch (the DAG's timezone, not yours), and a custom timetable that produces intervals you did not expect.

Then choose the reprocess behavior deliberately. Airflow offers options to skip runs that already exist, to rerun only failed ones, or to rerun all. For a repair after an outage, rerunning only failed intervals is nearly always right. Rerunning completed intervals overwrites good data with data produced under today's code.

Step 4: Order the runs

Run newest to oldest if the recent data matters most to consumers, and oldest to newest if tasks depend on the previous interval's output (depends_on_past). If you have depends_on_past, the reverse order will deadlock or skip. Check this before choosing.

Step 5: Watch the right things

Do not watch only the Airflow UI. Watch:

  • Warehouse queue depth and concurrent query count.
  • Source API rate-limit responses (429s). Retries on a backfill multiply the load. Consider a longer retry_delay for the duration.
  • Metadata database CPU. A backfill of many runs of many mapped tasks creates a lot of task instance rows. On a small managed environment this is the first thing to saturate.
  • Scheduler loop duration, if you run hundreds of DAGs. See our note on parsing time.

Have a stop plan. In Airflow 3 you can pause a backfill from the UI or API, which stops new runs from being created while in-flight ones finish. Know that before you start, and confirm it on your version in a non-production environment.

Step 6: Verify the result

A green run is not a correct run. Compare row counts and a checksum or aggregate per interval against a trusted source or against an earlier known-good partition. For estates mid-migration, the dual-run approach we describe elsewhere applies the same comparison.

The caveat for your estate

Everything above assumes the DAGs are idempotent and parameterized by interval. In most long-lived estates a fraction are not, and you will only find out which ones when a backfill duplicates a billing table. If you have not audited that, run the first backfill against a copy of the target tables, on a single interval, and diff. It costs an afternoon. It is cheaper than the alternative.