Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions airflow-core/src/airflow/jobs/scheduler_job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3156,11 +3156,7 @@ def _schedule_dag_run(
session.flush()
self.log.info("Run %s of %s has timed-out", dag_run.run_id, dag_run.dag_id)

if dag_run.state in State.finished_dr_states and dag_run.run_type in (
DagRunType.SCHEDULED,
DagRunType.MANUAL,
DagRunType.ASSET_TRIGGERED,
):
if dag_run.state in State.finished_dr_states and dag_run.run_type != DagRunType.BACKFILL_JOB:
self._set_exceeds_max_active_runs(dag_model=dag_model, session=session)

callback_to_execute: DagCallbackRequest | None = None
Expand Down Expand Up @@ -3224,11 +3220,7 @@ def _schedule_dag_run(
# TODO[HA]: Rename update_state -> schedule_dag_run, ?? something else?
schedulable_tis, callback_to_run = dag_run.update_state(session=session, execute_callbacks=False)

if dag_run.state in State.finished_dr_states and dag_run.run_type in (
DagRunType.SCHEDULED,
DagRunType.MANUAL,
DagRunType.ASSET_TRIGGERED,
):
if dag_run.state in State.finished_dr_states and dag_run.run_type != DagRunType.BACKFILL_JOB:
self._set_exceeds_max_active_runs(dag_model=dag_model, session=session)

# This will do one query per dag run. We "could" build up a complex
Expand Down
12 changes: 10 additions & 2 deletions airflow-core/tests/unit/jobs/test_scheduler_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -6039,34 +6039,42 @@ def test_should_use_info_from_timetable(self, mock_create, mock_next, expected,
)
assert actual == expected

@pytest.mark.parametrize("timed_out", [False, True], ids=["finished", "timed_out"])
@pytest.mark.parametrize(
("run_type", "expected"),
[
(DagRunType.MANUAL, True),
(DagRunType.SCHEDULED, True),
(DagRunType.BACKFILL_JOB, False),
(DagRunType.ASSET_TRIGGERED, True),
(DagRunType.OPERATOR_TRIGGERED, True),
(DagRunType.ASSET_MATERIALIZATION, True),
],
ids=[
DagRunType.MANUAL.name,
DagRunType.SCHEDULED.name,
DagRunType.BACKFILL_JOB.name,
DagRunType.ASSET_TRIGGERED.name,
DagRunType.OPERATOR_TRIGGERED.name,
DagRunType.ASSET_MATERIALIZATION.name,
],
)
def test_should_update_dag_next_dagruns_after_run_type(self, run_type, expected, session, dag_maker):
def test_should_update_dag_next_dagruns_after_run_type(
Comment thread
kaxil marked this conversation as resolved.
Resolved
self, run_type, expected, timed_out, session, dag_maker
):
"""Test that whether next dag run is updated depends on run type"""
with dag_maker(
schedule="*/1 * * * *",
max_active_runs=3,
dagrun_timeout=datetime.timedelta(seconds=60),
):
EmptyOperator(task_id="dummy")

run = dag_maker.create_dagrun(
run_id="run",
run_type=run_type,
logical_date=DEFAULT_DATE,
start_date=timezone.utcnow(),
start_date=timezone.utcnow() - datetime.timedelta(days=1) if timed_out else timezone.utcnow(),
state=State.SUCCESS,
session=session,
)
Expand Down