fix: limit clone job concurrency to prevent scheduler deadlock#227
Merged
fix: limit clone job concurrency to prevent scheduler deadlock#227
Conversation
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>
stuartwdouglas
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
MaxCloneConcurrencyconfig 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-concurrencyis not set (0), it defaults to half of total concurrency. For example, withconcurrency = 32, at most 16 workers will be used for clones, leaving 16 available for fetches and other jobs.Config: