fix(scheduler): start a tick's scans together; the slots cap them (#61) #823

Merged
sharang merged 1 commits from fix/scheduler-fan-out into main 2026-11-04 08:17:59 +00:00
Owner

Closes #61.

Why

scan_all_repos awaited each target's run_target_scan in turn, and the tick awaited each tenant in turn. So for scheduled scans:

  • one slow repository held up every other target;
  • SCAN_CONCURRENCY (the ScanGate slots) never came into play;
  • the 30 s start jitter, which is meant to spread concurrent starts, only added delay.

What

  • The tick starts every tenant's scans together (join_all).
  • scan_all_repos starts every target together (for_each_concurrent(None, …)).
  • run_target_scan is unchanged. It still:
    • takes the jitter;
    • coalesces with a running scan of the same target;
    • waits for a global slot.

So at most SCAN_CONCURRENCY scans run at once, exactly as for webhooks and manual scans.

Prod note

Prod runs SCAN_CONCURRENCY=1 since 03.11. (orca-platform #147), so prod behaviour stays one scan at a time until that goes back to 2.

Tests

No new unit test: the change is the loop shape, and the gating it relies on is covered by scan_gate's tests. Built in CI only.

🤖 Generated with Claude Code

Closes #61. ## Why `scan_all_repos` awaited each target's `run_target_scan` in turn, and the tick awaited each tenant in turn. So for scheduled scans: - one slow repository held up every other target; - `SCAN_CONCURRENCY` (the `ScanGate` slots) never came into play; - the 30 s start jitter, which is meant to spread concurrent starts, only added delay. ## What - The tick starts every tenant's scans together (`join_all`). - `scan_all_repos` starts every target together (`for_each_concurrent(None, …)`). - `run_target_scan` is unchanged. It still: - takes the jitter; - coalesces with a running scan of the same target; - waits for a global slot. So at most `SCAN_CONCURRENCY` scans run at once, exactly as for webhooks and manual scans. ## Prod note Prod runs `SCAN_CONCURRENCY=1` since 03.11. (orca-platform #147), so prod behaviour stays one scan at a time until that goes back to 2. ## Tests No new unit test: the change is the loop shape, and the gating it relies on is covered by `scan_gate`'s tests. Built in CI only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-04 08:00:14 +00:00
fix(scheduler): start a tick's scans together; the slots cap them (#61)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Agent integration (pull_request) Successful in 4m25s
CI / Check (pull_request) Successful in 17m11s
6f8a2f72da
The scan tick awaited every tenant and every target one after another,
so one slow repository held up all the others and SCAN_CONCURRENCY never
applied to scheduled scans. The tick now starts them all; each scan
waits for one of the SCAN_CONCURRENCY slots (ScanGate), and the existing
start jitter of up to 30 s spreads them out.

Closes #61.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit 93b98965b3 into main 2026-11-04 08:17:59 +00:00
Sign in to join this conversation.