Просмотр исходного кода

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 год назад
Родитель
Сommit
fd011f0149
1 измененных файлов с 3 добавлено и 3 удалено
  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):
     q = _soft_delete_aware_query(context, models.MinionPool)
     if include_machines:
-        q = q.options(orm.joinedload('minion_machines'))
+        q = q.options(orm.selectinload('minion_machines'))
     if include_events:
-        q = q.options(orm.joinedload('events'))
+        q = q.options(orm.selectinload('events'))
     if include_progress_updates:
-        q = q.options(orm.joinedload('progress_updates'))
+        q = q.options(orm.selectinload('progress_updates'))
     if is_user_context(context):
         q = q.filter(
             models.MinionPool.project_id == context.project_id)