Skip to content

Commit b29dda0

Browse files
committed
Fix empty fleet select
1 parent 8bdba43 commit b29dda0

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/dstack/_internal/server/background/scheduled_tasks/submitted_jobs.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from datetime import datetime, timedelta
66
from typing import List, Optional, Union
77

8-
from sqlalchemy import func, or_, select
8+
from sqlalchemy import exists, func, select
99
from sqlalchemy.ext.asyncio import AsyncSession
1010
from sqlalchemy.orm import (
1111
contains_eager,
@@ -596,12 +596,11 @@ async def _fetch_fleet_with_master_instance_provisioning_data(
596596
await sqlite_commit(session)
597597
res = await session.execute(
598598
select(FleetModel)
599-
.outerjoin(FleetModel.instances)
600599
.where(
601600
FleetModel.id == fleet_model.id,
602-
or_(
603-
InstanceModel.id.is_(None),
604-
InstanceModel.deleted == True,
601+
~exists().where(
602+
InstanceModel.fleet_id == fleet_model.id,
603+
InstanceModel.deleted == False,
605604
),
606605
)
607606
.with_for_update(key_share=True, of=FleetModel)

0 commit comments

Comments
 (0)