Why airflow UI shows next run in the past date and time

51 Views Asked by At

Airflow always showed "Next Run" as yesterday before today's run, and when today's run is done, it will show "Next Run" as today's date. For "Last Run", it was always the day before yesterday if today's run is not triggered. Once today's run is finished, "Last Run" will be yesterday. Changing the start_date of DAG didn't help at all.

I've set up my airflow default timezone as the local timezone, and UI as well.

Today is 2024-03-14, and I set up a dag with start date of 2024-03-12. This is scheduled to run at 20:20 every day.

with DAG(
    default_args=default_args,
    dag_id="test_dag2",
    description="dag with py operator",
    start_date=datetime(2024, 3, 12, tzinfo=local_tz),
    schedule_interval="20 20 * * *"
) as dag

First refreshed the page and "test_dag2" showed up and paused. enter image description here

Second, unpaused the dag and it ran for the previous days. The "Next Run" however, is 2024-03-13, which I expected to see 2024-03-14. enter image description here

And then, at 2024-03-14 20:20, the dag ran and the status was updated in UI, showing "Last Run" as yesterday 2024-03-13, and "Next Run" will be today 2024-03-14. enter image description here

Checked DagRun still showed the same: it was scheduled to be run on 2024-03-13, but we can see it was queued at 2024-03-14 (converted UTC to local time in red, though they showed the same date). enter image description here

And then I made a manual run, in which "Last Run" was showing the correct date - 2024-03-14. So manual run always shows the correct date and time, while scheduled run is always a date late. enter image description here

Why "Last Run" and "Next Run" do not show the correct date? Why are they always one day behind the actual run date (both UTC and local date)?

1

There are 1 best solutions below

1
mujiannan On

That's Time Window.
By default, "next run" display the start of next Time Window, which is called data_interval_start.

Every "dag run" has its data interval.

Airflow Documentation: What does execution_date mean?