Browse Source

Fix cartesian product on minion pool fetching

When multiple `joinedload`s were queried, it resulted in a cartesian product
list of rows. Switching to `selectinload`, while performing multiple queries
to the DB server, will make sure that the minimum amount of rows get returned
from the DB. This fixes hangups when fetching progress updates and events of
long-running minion pools.
Daniel Vincze 1 year ago
parent
commit
fd011f0149
1 changed files with 3 additions and 3 deletions
  1. 3 3
      coriolis/db/api.py

+ 3 - 3
coriolis/db/api.py

@@ -1399,11 +1399,11 @@ def get_minion_pool(
         include_events=False, include_progress_updates=False):
         include_events=False, include_progress_updates=False):
     q = _soft_delete_aware_query(context, models.MinionPool)
     q = _soft_delete_aware_query(context, models.MinionPool)
     if include_machines:
     if include_machines:
-        q = q.options(orm.joinedload('minion_machines'))
+        q = q.options(orm.selectinload('minion_machines'))
     if include_events:
     if include_events:
-        q = q.options(orm.joinedload('events'))
+        q = q.options(orm.selectinload('events'))
     if include_progress_updates:
     if include_progress_updates:
-        q = q.options(orm.joinedload('progress_updates'))
+        q = q.options(orm.selectinload('progress_updates'))
     if is_user_context(context):
     if is_user_context(context):
         q = q.filter(
         q = q.filter(
             models.MinionPool.project_id == context.project_id)
             models.MinionPool.project_id == context.project_id)