After an Airflow 2 → 3 upgrade a daily DAG loads empty, shifted partitions and stopped filling gaps — why?
This DAG ran correctly for a year on Airflow 2.10. Nothing in it changed during the upgrade to Airflow 3. Since then: every load succeeds but inserts 0 rows; the run that fires on Mar 10 at 03:00 writes partition dt=2026-03-10 where it used to write dt=2026-03-09; the success callback raises KeyError: 'execution_date'; and after a 5-day pause, unpausing ran only the latest day.
import pendulum
from airflow import DAG
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
def notify(context):
send_report(context["execution_date"])
with DAG(
dag_id="events_daily",
start_date=pendulum.datetime(2025, 1, 1, tz="UTC"),
schedule="0 3 * * *",
on_success_callback=notify,
):
SQLExecuteQueryOperator(
task_id="load",
conn_id="dwh",
sql="""
INSERT INTO events_daily PARTITION (dt = '{{ ds }}')
SELECT * FROM raw_events
WHERE ts >= '{{ data_interval_start }}'
AND ts < '{{ data_interval_end }}'
""",
)Diagnose the cause of each symptom and fix the DAG so it behaves as it did on Airflow 2.
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.
- 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
- 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?
All four symptoms are Airflow 3 default changes, not bugs in the DAG code.
- 0 rows. The
create_cron_data_intervalsconfig is nowFalse, so the bare cron string"0 3 * * *"resolves toCronTriggerTimetable. Itsdata_interval_start == data_interval_end— the trigger time — sots >= X AND ts < Xselects nothing. - Shifted partition. A
CronTriggerTimetablerun's logical date is its trigger time (Mar 10 03:00); an interval timetable's is the interval start (Mar 9 03:00).dscomes from the logical date, hencedt=2026-03-10. KeyError. Airflow 3 removedexecution_datefrom the task context.- No gap fill.
catchup_by_defaultisFalsein Airflow 3, and the DAG never setcatchup.
import pendulum
from airflow.sdk import DAG, CronDataIntervalTimetable
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
def notify(context):
send_report(context["logical_date"])
with DAG(
dag_id="events_daily",
start_date=pendulum.datetime(2025, 1, 1, tz="UTC"),
schedule=CronDataIntervalTimetable("0 3 * * *", timezone="UTC"),
catchup=True,
on_success_callback=notify,
):
SQLExecuteQueryOperator(
task_id="load",
conn_id="dwh",
sql="""
INSERT INTO events_daily PARTITION (dt = '{{ ds }}')
SELECT * FROM raw_events
WHERE ts >= '{{ data_interval_start }}'
AND ts < '{{ data_interval_end }}'
""",
)Instead of an explicit timetable in every DAG you can set [scheduler] create_cron_data_intervals = True for the whole deployment, but set it before the upgrade: flipped after Airflow 3 runs exist, it skips one scheduled run in every affected DAG. A timetable declared in the DAG does not depend on environment config. Set catchup explicitly in every DAG as well.