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


Reply via email to