feat(daemon): run sync passes on a worker pool

The loop thread schedules and sync.workers threads (default 4) run passes,
so a slow or hanging fetch no longer holds up every other repo. A repo never
has two passes at once; passes go only to idle workers, so pause and backoff
behave as before. Visibility and merged-PR caches are shared without holding
locks across forge requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-11-17 16:02:41 +01:00
1 parent 6e5bee1a95
commit f16438fa02
7 files changed
+317 -127

No files matched your search

+24
View File
@@ -768,3 +768,27 @@ fn clone_appears_only_when_complete() {
assert!(seen, "cloned repo never managed");
d.shutdown();
}
#[test]
fn a_hanging_fetch_does_not_hold_up_other_repos() {
let w = world("workers", &["pca"]);
// `a-slow` sorts first, so its pass is dispatched first; its fetch hangs for 15 s.
let slow = w.base.join("pca/g/a-slow");
bare_layout(&slow, &w.remote);
let bare = slow.join(".bare");
git(
&bare,
&["remote", "set-url", "origin", "ssh://hang.invalid/x.git"],
);
git(&bare, &["config", "core.sshCommand", "sleep 15; false"]);
let mut cfg = config(&w, "pca", 200, 60);
cfg.sync.workers = 2;
let started = Instant::now();
let d = Daemon::start(cfg, settings(&w, "pca")).unwrap();
fs::write(w.base.join("pca/g/repo/main/new.txt"), "x\n").unwrap();
wait_until("snapshot of the other repo pushed", 10, || {
!git(&w.remote, &["for-each-ref", "refs/sync/pca/"]).is_empty()
});
assert!(started.elapsed() < Duration::from_secs(12));
d.shutdown();
}