|
20 | 20 | RunTerminationReason, |
21 | 21 | ) |
22 | 22 | from dstack._internal.server.db import get_db, get_session_ctx |
23 | | -from dstack._internal.server.models import JobModel, ProjectModel, RunModel |
| 23 | +from dstack._internal.server.models import JobModel, ProjectModel, RunModel, UserModel |
24 | 24 | from dstack._internal.server.services.jobs import ( |
25 | 25 | find_job, |
26 | 26 | get_job_specs_from_run_spec, |
@@ -129,14 +129,12 @@ async def _process_next_run(): |
129 | 129 | async def _process_run(session: AsyncSession, run_model: RunModel): |
130 | 130 | logger.debug("%s: processing run", fmt(run_model)) |
131 | 131 | # Refetch to load related attributes. |
132 | | - # joinedload produces LEFT OUTER JOIN that can't be used with FOR UPDATE. |
133 | 132 | res = await session.execute( |
134 | 133 | select(RunModel) |
135 | 134 | .where(RunModel.id == run_model.id) |
136 | 135 | .execution_options(populate_existing=True) |
137 | | - .options(joinedload(RunModel.project).joinedload(ProjectModel.backends)) |
138 | | - .options(joinedload(RunModel.user)) |
139 | | - .options(joinedload(RunModel.repo)) |
| 136 | + .options(joinedload(RunModel.project).load_only(ProjectModel.id, ProjectModel.name)) |
| 137 | + .options(joinedload(RunModel.user).load_only(UserModel.name)) |
140 | 138 | .options(selectinload(RunModel.jobs).joinedload(JobModel.instance)) |
141 | 139 | .execution_options(populate_existing=True) |
142 | 140 | ) |
|
0 commit comments