You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "daniel-dylag-openx (via GitHub)" <gi...@apache.org> on 2023/09/01 19:21:26 UTC

[GitHub] [airflow] daniel-dylag-openx commented on a diff in pull request #34021: Fix scheduler logic to plan new dag runs by ignoring manual runs

daniel-dylag-openx commented on code in PR #34021:
URL: https://github.com/apache/airflow/pull/34021#discussion_r1313357554


##########
airflow/jobs/scheduler_job_runner.py:
##########
@@ -1300,9 +1300,16 @@ def _create_dag_runs_dataset_triggered(
                 )
 
     def _should_update_dag_next_dagruns(
-        self, dag: DAG, dag_model: DagModel, total_active_runs: int | None = None, *, session: Session
+        self, dag: DAG, dag_model: DagModel, last_dag_run: DagRun | None = None,
+        total_active_runs: int | None = None, *, session: Session
     ) -> bool:
-        """Check if the dag's next_dagruns_create_after should be updated."""
+        """Check if the dag's next_dagruns_create_after should be updated.
+        If last_dag_run is defined, the update was triggered by a scheduling decision in this DAG run
+        """
+        # If last_dag_run is defined, schedule next only if last_dag_run is finished and was an automated run
+        if last_dag_run and not (last_dag_run.state in State.finished_dr_states and
+           last_dag_run.run_type in [DagRunType.SCHEDULED, DagRunType.BACKFILL_JOB]):

Review Comment:
   This is the actual bugfix: previously we didn't check run type so manual runs were messing with scheduling decisions. Compare it with https://github.com/apache/airflow/blob/3ae6b4e86fe807c00bd736c59df58733df2b9bf9/airflow/models/dag.py#L2943 where exact same filtering is applied before eventually invoking `calculate_dagrun_date_fields` for filtered dag runs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org