You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/08/06 22:47:00 UTC

[jira] [Commented] (AIRFLOW-2787) Airflow scheduler dies on DAGs with NULL DagRun run_id

    [ https://issues.apache.org/jira/browse/AIRFLOW-2787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16570878#comment-16570878 ] 

ASF GitHub Bot commented on AIRFLOW-2787:
-----------------------------------------

feng-tao closed pull request #3629: AIRFLOW-2787 Allow is_backfill to handle NULL DagRun.run_id
URL: https://github.com/apache/incubator-airflow/pull/3629
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/models.py b/airflow/models.py
index cf7eb0a64f..288bd4c937 100755
--- a/airflow/models.py
+++ b/airflow/models.py
@@ -5141,7 +5141,10 @@ def get_run(session, dag_id, execution_date):
     @property
     def is_backfill(self):
         from airflow.jobs import BackfillJob
-        return self.run_id.startswith(BackfillJob.ID_PREFIX)
+        return (
+            self.run_id is not None and
+            self.run_id.startswith(BackfillJob.ID_PREFIX)
+        )
 
     @classmethod
     @provide_session
diff --git a/tests/models.py b/tests/models.py
index 1c88ea47f7..914b8bc6c4 100644
--- a/tests/models.py
+++ b/tests/models.py
@@ -946,11 +946,20 @@ def test_get_latest_runs(self):
 
     def test_is_backfill(self):
         dag = DAG(dag_id='test_is_backfill', start_date=DEFAULT_DATE)
+
         dagrun = self.create_dag_run(dag, execution_date=DEFAULT_DATE)
         dagrun.run_id = BackfillJob.ID_PREFIX + '_sfddsffds'
-        dagrun2 = self.create_dag_run(dag, execution_date=DEFAULT_DATE + datetime.timedelta(days=1))
+
+        dagrun2 = self.create_dag_run(
+            dag, execution_date=DEFAULT_DATE + datetime.timedelta(days=1))
+
+        dagrun3 = self.create_dag_run(
+            dag, execution_date=DEFAULT_DATE + datetime.timedelta(days=2))
+        dagrun3.run_id = None
+
         self.assertTrue(dagrun.is_backfill)
         self.assertFalse(dagrun2.is_backfill)
+        self.assertFalse(dagrun3.is_backfill)
 
     def test_removed_task_instances_can_be_restored(self):
         def with_all_tasks_removed(dag):


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Airflow scheduler dies on DAGs with NULL DagRun run_id
> ------------------------------------------------------
>
>                 Key: AIRFLOW-2787
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-2787
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: George Leslie-Waksman
>            Priority: Critical
>
> When a DagRun is created with NULL run_id, the scheduler subprocess will crash when checking `is_backfill`:
> {noformat}
> Got an exception! Propagating...
> Traceback (most recent call last):
>   File "/usr/local/lib/python3.6/site-packages/airflow/jobs.py", line 347, in helper
>     pickle_dags)
>   File "/usr/local/lib/python3.6/site-packages/airflow/utils/db.py", line 53, in wrapper
>     result = func(*args, **kwargs)
>   File "/usr/local/lib/python3.6/site-packages/airflow/jobs.py", line 1583, in process_file
>     self._process_dags(dagbag, dags, ti_keys_to_schedule)
>   File "/usr/local/lib/python3.6/site-packages/airflow/jobs.py", line 1175, in _process_dags
>     self._process_task_instances(dag, tis_out)
>   File "/usr/local/lib/python3.6/site-packages/airflow/jobs.py", line 873, in _process_task_instances
>     if run.is_backfill:
>   File "/usr/local/lib/python3.6/site-packages/airflow/models.py", line 4257, in is_backfill
>     if "backfill" in self.run_id:
> TypeError: argument of type 'NoneType' is not iterable
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)