Skip to content

fix: limit clone job concurrency to prevent scheduler deadlock#227

Merged
worstell merged 1 commit intomainfrom
worstell/scheduler-clone-concurrency-limit
Mar 26, 2026
Merged

fix: limit clone job concurrency to prevent scheduler deadlock#227
worstell merged 1 commit intomainfrom
worstell/scheduler-clone-concurrency-limit

Conversation

@worstell
Copy link
Copy Markdown
Contributor

@worstell worstell commented Mar 26, 2026

Clone operations can take up to 30 minutes (CloneTimeout). When many simultaneous clones occur, they can consume all scheduler workers, starving fetch/repack/snapshot jobs and causing refs to go stale across all repos — resulting in a full service outage.

This adds a MaxCloneConcurrency config option to the scheduler that limits how many clone/deferred-mirror-restore jobs can run simultaneously. Remaining worker slots are reserved for fetch/repack/snapshot jobs, preventing clone starvation from causing a system-wide deadlock.

Default behavior: When max-clone-concurrency is not set (0), it defaults to half of total concurrency. For example, with concurrency = 32, at most 16 workers will be used for clones, leaving 16 available for fetches and other jobs.

Config:

scheduler {
  concurrency = 32
  max-clone-concurrency = 8  # optional, defaults to concurrency/2
}

Clone operations can take up to 30 minutes (CloneTimeout). When many
simultaneous clones occur, they can consume all scheduler workers,
starving fetch/repack/snapshot jobs and causing a full service outage.

Add MaxCloneConcurrency config to limit how many clone jobs can run
simultaneously, reserving remaining workers for other job types.

Default: half of total concurrency (e.g., 4 of 8 workers for clones,
leaving 4 for fetches/repacks/snapshots).

Amp-Thread-ID: https://ampcode.com/threads/T-019d2b6c-0ae0-768e-b01c-7069931d6562
Co-authored-by: Amp <amp@ampcode.com>
@worstell worstell requested a review from a team as a code owner March 26, 2026 20:04
@worstell worstell requested review from jrobotham-square and removed request for a team March 26, 2026 20:04
@worstell worstell merged commit 28e03c0 into main Mar 26, 2026
7 checks passed
@worstell worstell deleted the worstell/scheduler-clone-concurrency-limit branch March 26, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants