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 2019/04/30 18:08:35 UTC

[GitHub] [airflow] ashb commented on a change in pull request #5210: [AIRFLOW-4419] Restore used_slots and queued_slots Pool methods

ashb commented on a change in pull request #5210: [AIRFLOW-4419] Restore used_slots and queued_slots Pool methods
URL: https://github.com/apache/airflow/pull/5210#discussion_r279872474
 
 

 ##########
 File path: airflow/models/pool.py
 ##########
 @@ -64,6 +95,8 @@ def open_slots(self, session):
         from airflow.models.taskinstance import \
             TaskInstance as TI  # Avoid circular import
 
+        # Issue a single query instead of using the used_slots/queued_slots to
+        # avoid load on DB
         used_slots = session.query(func.count()).filter(TI.pool == self.pool).filter(
             TI.state.in_([State.RUNNING, State.QUEUED])).scalar()
         return self.slots - used_slots
 
 Review comment:
   I think it still is? used_slots was State.RUNNING, and queued_slots was State.QUEUED.
   
   So now its `slots - (count RUNNING or QUEUED)` = `slots - RUNNING - QUEUED` (just via one query than two).
   
   I think. It's been a long day.

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


With regards,
Apache Git Services