Airflow Orchestration
DAGs, scheduling and data intervals, catchup and backfills, retries, sensors, and the Airflow 3 changes.
10 questions
JuniorTheoryVery commonHow do a DAG, an operator, a task, a DAG run and a task instance relate in Airflow?
How do a DAG, an operator, a task, a DAG run and a task instance relate in Airflow?
A DAG is the pipeline definition; an operator is a class, and a task is a DAG node built from one. A DAG run is one execution for one logical date; a task instance is one task in one DAG run — it holds the state retries and clear act on.
Common mistakes
- ✗Using task and task instance interchangeably, as if a task had one state shared by all runs
- ✗Treating the operator as the node itself rather than the class a task is built from
- ✗Thinking clear or a retry re-executes the whole DAG run instead of selected task instances
Follow-up questions
- →What happens to downstream task instances when you clear one upstream task instance?
- →Which task instance states can a DAG run end in, and how is the run's own state derived?
JuniorTheoryVery commonOn a daily schedule, when does the run for Jan 15 fire and which data interval does it carry?
On a daily schedule, when does the run for Jan 15 fire and which data interval does it carry?
The logical date is data_interval_start. Under an interval timetable (Airflow 2's cron default) the Jan 15 run covers Jan 15–16 and fires when it closes, on Jan 16. In Airflow 3 a bare @daily is CronTriggerTimetable: it fires on Jan 15 with start = end.
Common mistakes
- ✗Assuming a run fires at the start of its interval, so the Jan 15 run would read a day that has not happened yet
- ✗Carrying Airflow 2's one-period-late behaviour into Airflow 3, where a bare cron string gives a zero-length interval
- ✗Equating the logical date with the wall-clock time the run started
Follow-up questions
- →How do you make a bare cron string in Airflow 3 produce full data intervals again?
- →Which template variables would a daily load use to select exactly its interval's rows?
MiddleDebuggingVery commonA daily DAG unpaused on Airflow 2 queued about 365 runs at once — find the cause and fix it
A daily DAG unpaused on Airflow 2 queued about 365 runs at once — find the cause and fix it
Catchup creates a DAG run for every missed interval since start_date, and it defaults to True in Airflow 2 (False in Airflow 3). Set catchup=False on the DAG so both versions agree, and load the 30 days with an explicit backfill, which has its own max_active_runs.
Common mistakes
- ✗Trusting the catchup default, which flipped from True in Airflow 2 to False in Airflow 3
- ✗Using a dynamic
start_datesuch asdatetime.now()to dodge catchup - ✗Treating catchup and backfill as one thing instead of automatic versus explicit runs over past intervals
Follow-up questions
- →How does a backfill in Airflow 3 treat intervals that already have a successful run?
- →Why must the load be idempotent before you run catchup or a backfill over it?
JuniorTheoryCommonWhat does each Airflow 3 component do, and what keeps running when the scheduler is down?
What does each Airflow 3 component do, and what keeps running when the scheduler is down?
The DAG processor parses DAG files, the scheduler creates runs and queues ready tasks, the executor hands them to workers, the triggerer waits on deferred ones. State lives in the metadata DB, reached by Airflow 3 task code via the API server. Scheduler down: running tasks finish, nothing new is queued.
Common mistakes
- ✗Believing the scheduler executes task code itself rather than handing it to an executor and workers
- ✗Assuming task code in Airflow 3 can still open metadata DB sessions directly
- ✗Treating the triggerer as a failover scheduler instead of the process that waits on deferred tasks
Follow-up questions
- →Why did Airflow 3 move task code off direct metadata DB access onto the worker-facing Task Execution API?
- →How does a scheduler outage differ under LocalExecutor versus CeleryExecutor?
JuniorTheoryCommonHow do retries and retry_delay work in Airflow, and which failures are worth retrying?
How do retries and retry_delay work in Airflow, and which failures are worth retrying?
They act per task instance: a failed try enters up_for_retry and reruns after retry_delay, which retry_exponential_backoff grows. Retry transient faults — timeouts, 5xx, locks. Bad data, auth or SQL errors fail every try, so retrying only delays on_failure_callback.
Common mistakes
- ✗Retrying deterministic failures such as bad data or wrong credentials, which only postpones the alert
- ✗Believing a retry reruns the whole DAG run rather than the single task instance
- ✗Expecting
on_failure_callbackto fire on every failed try instead of after the last one
Follow-up questions
- →How would you make a task fail immediately on a known non-retryable error despite
retries? - →Why must a task be idempotent before you give it retries?
MiddleCodeCommonRewrite an Airflow task that picks its day with datetime.now() so retries and backfills are safe
Rewrite an Airflow task that picks its day with datetime.now() so retries and backfills are safe
datetime.now() ties the slice to the clock, so a retry after midnight or a backfill loads another day under an old run and appends it again. Read data_interval_start/data_interval_end from the context (not execution_date, gone in Airflow 3) and overwrite that range.
Common mistakes
- ✗Fixing the date source but keeping an append, so a retry of the same run still doubles the interval
- ✗Reaching for
execution_date, which Airflow 3 removed from the task context - ✗Filtering on the interval under Airflow 3's default cron timetable, where start equals end and the filter is empty
Follow-up questions
- →How would the same task pass the interval to a SQL operator through Jinja templates instead?
- →What changes if the target table is partitioned by day and supports partition overwrite?
MiddlePerformanceCommonFifty Airflow sensors waiting on files leave no free worker slots — why, and what fixes it?
Fifty Airflow sensors waiting on files leave no free worker slots — why, and what fixes it?
In poke mode, the default, a sensor holds its worker and pool slot for the whole wait, so 50 waiting sensors starve the workers. reschedule frees the slot between checks (up_for_reschedule); a deferrable operator hands the wait to the triggerer.
Common mistakes
- ✗Believing a poking sensor releases its worker slot between checks
- ✗Tuning
poke_intervalto fix starvation when the cause is the mode - ✗Using
reschedulefor checks every few seconds, where rescheduling overhead outweighs the freed slot
Follow-up questions
- →Why can a sensor in
reschedulemode not keep state in memory between checks? - →When does a deferrable operator beat
reschedulemode, and what does it need running?
MiddleDebuggingCommonA DAG file calls an API and reads a Variable at import time — why does every DAG slow down?
A DAG file calls an API and reads a Variable at import time — why does every DAG slow down?
The DAG processor re-imports every DAG file in a loop, so top-level code runs on each parse, not per run: the HTTP call and Variable.get fire every cycle, slow parsing of all files, risk dagbag_import_timeout and hammer the source. Move them into the task.
Common mistakes
- ✗Assuming module-level code runs once per DAG run rather than on every parse of the file
- ✗Thinking a slow DAG file only hurts its own DAG, when it delays parsing for every file
- ✗Keeping
Variable.getat module level instead of reading it in the task or a template
Follow-up questions
- →Which settings control how often DAG files are re-parsed and how long one import may take?
- →How would you pass the Variable through a Jinja template such as
var.valueinstead?
SeniorDesignOccasionalEvery night an upstream system drops a varying number of files — from none to about 900 — into an object-store prefix. Each file must be validated and loaded by its own task, so that one bad file can be retried on its own without reloading the rest. A teammate proposes listing the prefix at the top of the DAG file and creating one task per file in a Python loop. The DAG runs on Airflow 3, the warehouse accepts at most 16 concurrent loads, and the run history must show the same DAG structure from night to night. How would you build the per-file fan-out, and why not the parse-time loop?
Every night an upstream system drops a varying number of files — from none to about 900 — into an object-store prefix. Each file must be validated and loaded by its own task, so that one bad file can be retried on its own without reloading the rest. A teammate proposes listing the prefix at the top of the DAG file and creating one task per file in a Python loop. The DAG runs on Airflow 3, the warehouse accepts at most 16 concurrent loads, and the run history must show the same DAG structure from night to night. How would you build the per-file fan-out, and why not the parse-time loop?
Use dynamic task mapping: an upstream task lists the prefix at run time and returns paths, and load.expand(path=...) makes one mapped task instance per file, retried alone. A parse-time loop runs I/O on every parse and reshapes the DAG. Pass paths, not data; cap loads at 16.
Common mistakes
- ✗Building tasks from a list fetched at parse time, which runs I/O on every parse and changes the DAG's shape
- ✗Passing file contents through the mapped input instead of small references such as paths
- ✗Capping concurrency with the DAG's
max_active_runs, which limits runs, not task instances
Follow-up questions
- →What does a mapped task do when the upstream list is empty, and how does the run end?
- →Which limit on the number of mapped task instances would a 2,000-file night hit, and how do you raise it?
SeniorDebuggingOccasionalAfter an Airflow 2 → 3 upgrade a daily DAG loads empty, shifted partitions and stopped filling gaps — why?
After an Airflow 2 → 3 upgrade a daily DAG loads empty, shifted partitions and stopped filling gaps — why?
In Airflow 3 a bare cron string means CronTriggerTimetable: start = end = trigger time, so the interval filter is empty and ds moves to the trigger day. execution_date left the context; catchup now defaults to False. Pin CronDataIntervalTimetable, use logical_date, set catchup=True.
Common mistakes
- ✗Assuming a cron string still yields full data intervals in Airflow 3, as it did in Airflow 2
- ✗Replacing
execution_datewith the run's start time instead oflogical_dateordata_interval_start - ✗Relying on the catchup default, which flipped to False in Airflow 3
Follow-up questions
- →When is the zero-length interval of
CronTriggerTimetableactually the right choice? - →How would you find every DAG in a repository affected by these three changes before upgrading?