uranusjr commented on PR #60166:
URL: https://github.com/apache/airflow/pull/60166#issuecomment-3722230675

   Thinking about it, the deadlock isn’t really caused by the subquery, right? 
Would this be good enough to resolve the issue on MySQL?
   
   ```python
   if session.scalar(select(func.count()).where(DagModel.is_stale).limit(1)):
       for model in models_to_check:
           session.execute(
               delete(model)
               
.where(model.dag_id.in_(select(DagModel.dag_id).where(DagModel.is_stale)))
               .execution_options(synchronize_session="fetch")
           )
   
   ```
   
   This would avoid fetching in a list with unchecked size and should be safe 
everywhere.


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

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to