uranusjr commented on code in PR #22701:
URL: https://github.com/apache/airflow/pull/22701#discussion_r845867452


##########
airflow/jobs/backfill_job.py:
##########
@@ -784,6 +786,31 @@ def _execute(self, session=None):
                 return
             dagrun_infos = [DagRunInfo.interval(dagrun_start_date, 
dagrun_end_date)]
 
+        dag_with_subdags_ids = [d.dag_id for d in self._get_dag_with_subdags()]
+        running_dagruns = DagRun.find(
+            dag_id=dag_with_subdags_ids,
+            execution_start_date=self.bf_start_date,
+            execution_end_date=self.bf_end_date,
+            no_backfills=True,
+            state=DagRunState.RUNNING,
+        )
+
+        if running_dagruns:
+            for run in running_dagruns:
+                self.log.error(
+                    "Backfill cannot be created for DagRun %s in %s, as 
there's already %s in a RUNNING "
+                    "state.",
+                    run.dag_id,
+                    run.execution_date.strftime("%Y-%m-%dT%H:%M:%S"),

Review Comment:
   Why not use `run.run_id` here?



##########
airflow/jobs/backfill_job.py:
##########
@@ -784,6 +786,31 @@ def _execute(self, session=None):
                 return
             dagrun_infos = [DagRunInfo.interval(dagrun_start_date, 
dagrun_end_date)]
 
+        dag_with_subdags_ids = [d.dag_id for d in self._get_dag_with_subdags()]
+        running_dagruns = DagRun.find(
+            dag_id=dag_with_subdags_ids,
+            execution_start_date=self.bf_start_date,
+            execution_end_date=self.bf_end_date,
+            no_backfills=True,
+            state=DagRunState.RUNNING,
+        )
+
+        if running_dagruns:
+            for run in running_dagruns:
+                self.log.error(
+                    "Backfill cannot be created for DagRun %s in %s, as 
there's already %s in a RUNNING "
+                    "state.",
+                    run.dag_id,
+                    run.execution_date.strftime("%Y-%m-%dT%H:%M:%S"),

Review Comment:
   Why not use `run.run_id` here?



##########
airflow/jobs/backfill_job.py:
##########
@@ -290,7 +290,6 @@ def _get_dag_run(self, dagrun_info: DagRunInfo, dag: DAG, 
session: Session = Non
         current_active_dag_count = 
dag.get_num_active_runs(external_trigger=False)
 
         # check if we are scheduling on top of a already existing dag_run
-        # we could find a "scheduled" run instead of a "backfill"

Review Comment:
   Is this removed intentionally and why?



##########
airflow/jobs/backfill_job.py:
##########
@@ -290,7 +290,6 @@ def _get_dag_run(self, dagrun_info: DagRunInfo, dag: DAG, 
session: Session = Non
         current_active_dag_count = 
dag.get_num_active_runs(external_trigger=False)
 
         # check if we are scheduling on top of a already existing dag_run
-        # we could find a "scheduled" run instead of a "backfill"

Review Comment:
   Is this removed intentionally and why?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to