File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
src/dstack/_internal/server/background/tasks Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 33
44from sqlalchemy import select
55from sqlalchemy .ext .asyncio import AsyncSession
6- from sqlalchemy .orm import joinedload
76
87from dstack ._internal .core .models .profiles import parse_duration
98from dstack ._internal .core .models .volumes import VolumeStatus
@@ -31,13 +30,14 @@ async def process_idle_volumes(batch_size: int = 10):
3130 VolumeModel .deleted == False ,
3231 VolumeModel .id .not_in (lockset ),
3332 )
34- .options (joinedload (VolumeModel .project ))
35- .options (joinedload (VolumeModel .attachments ))
3633 .order_by (VolumeModel .last_processed_at .asc ())
3734 .limit (batch_size )
3835 .with_for_update (skip_locked = True )
3936 )
4037 volume_models = list (res .unique ().scalars ().all ())
38+ # Manually load relationships to avoid outer join in the locked query
39+ for volume_model in volume_models :
40+ await session .refresh (volume_model , ["project" , "attachments" ])
4141 if not volume_models :
4242 return
4343
You can’t perform that action at this time.
0 commit comments