You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/03/15 15:57:21 UTC

[GitHub] [airflow] ephraimbuddy commented on a change in pull request #14776: Fix running child tasks in a subdag after clearing a successful subdag

ephraimbuddy commented on a change in pull request #14776:
URL: https://github.com/apache/airflow/pull/14776#discussion_r594463338



##########
File path: airflow/models/dag.py
##########
@@ -1112,17 +1112,19 @@ def topological_sort(self, include_subdag_tasks: bool = False):
     @provide_session
     def set_dag_runs_state(
         self,
+        dag_ids: List[str] = None,
         state: str = State.RUNNING,
         session: Session = None,
         start_date: Optional[datetime] = None,
         end_date: Optional[datetime] = None,
     ) -> None:
-        query = session.query(DagRun).filter_by(dag_id=self.dag_id)
+        dag_ids = dag_ids or [self.dag_id]
+        query = session.query(DagRun).filter(DagRun.dag_id.in_(dag_ids))
         if start_date:
             query = query.filter(DagRun.execution_date >= start_date)
         if end_date:
             query = query.filter(DagRun.execution_date <= end_date)
-        query.update({DagRun.state: state})
+        query.update({DagRun.state: state}, synchronize_session=False)

Review comment:
       Yes. It's needed, without it, it raises `InvalidRequestError`.  However, after reading about the options, I think the `fetch` option is the right one. What do you think?




----------------------------------------------------------------
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.

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