Skip to content

Bug: No concurrent fleet sync guard — duplicate syncs can conflict #1730

@mrveiss

Description

@mrveiss

Problem

Nothing prevents triggering a second fleet sync via POST /api/code-sync/fleet/sync while one is already running. Two concurrent syncs could:

  • Deploy to the same nodes simultaneously
  • Cause Ansible playbook conflicts
  • Trigger git index.lock race conditions (CLAUDE.md already warns: use batch_size=1)
  • Produce confusing job status (two "running" jobs for same nodes)

Expected

The endpoint should reject a new fleet sync if one is already status='running', returning a 409 Conflict with the existing job_id.

Fix

In sync_fleet(), before creating a new job:

# Check for running jobs
running = await db.execute(
    select(FleetSyncJobModel).where(FleetSyncJobModel.status == "running")
)
if running.scalar_one_or_none():
    raise HTTPException(409, "Fleet sync already in progress")

Impact

Severity: medium — can cause deployment failures and confusing state

Discovered During

Implementing #1707 — fleet sync job DB persistence

Location

autobot-slm-backend/api/code_sync.pysync_fleet() endpoint

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions