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/10/14 11:54:31 UTC

[GitHub] [airflow] uranusjr commented on a change in pull request #18975: Row lock TI query in SchedulerJob._process_executor_events

uranusjr commented on a change in pull request #18975:
URL: https://github.com/apache/airflow/pull/18975#discussion_r728906466



##########
File path: airflow/jobs/scheduler_job.py
##########
@@ -510,7 +510,15 @@ def _process_executor_events(self, session: Session = None) -> int:
 
         # Check state of finished tasks
         filter_for_tis = TI.filter_for_tis(tis_with_right_state)
-        tis: List[TI] = session.query(TI).filter(filter_for_tis).options(selectinload('dag_model')).all()
+        query = session.query(TI).filter(filter_for_tis).options(selectinload('dag_model'))
+        # row lock this entire set of tasks to make sure the scheduler doesn't fail when we have
+        # multi-schedulers
+        tis: List[TI] = with_row_locks(
+            query,
+            of=TI,
+            session=session,
+            **skip_locked(session=session),
+        ).all()

Review comment:
       ```suggestion
           tis: Iterator[TI] = with_row_locks(
               query,
               of=TI,
               session=session,
               **skip_locked(session=session),
           )
   ```
   
   Probably a good time to change this




-- 
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: commits-unsubscribe@airflow.apache.org

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