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 13:14:44 UTC

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

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



##########
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:
       Is `synchronize_session=False` needed here?, since if the session is passed it _might_ cause some issues I think.
   
   >False - don’t synchronize the session. This option is the most efficient and is reliable once the session is expired, which typically occurs after a commit(), or explicitly using expire_all(). Before the expiration, objects that were updated or deleted in the database may still remain in the session with stale values, which can lead to confusing results.
   
   




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