diff options
| author | aur-build <aur-build@localhost> | 2026-11-18 08:36:39 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-18 08:36:39 +0000 |
| commit | e27e90aa82b6c878e34b94a6fa238836f497b1c3 (patch) | |
| tree | 1667b469468192ea97d6d2d6aeb534e1ad5f0b46 /src/config.rs | |
| parent | eefbefed9cbea6b2edef65900fbe6cb6da0b48e4 (diff) | |
| download | aur-build-e27e90aa82b6c878e34b94a6fa238836f497b1c3.tar.gz aur-build-e27e90aa82b6c878e34b94a6fa238836f497b1c3.zip | |
pipeline: dispatcher actor, worker pool and reaper (§8.2, §8.4)
One dispatcher thread, N workers, one crossbeam channel between them. The
dispatcher loop is reap -> cancel -> claim -> send, and the reaper runs first
on every pass including the first, so 'recover from a crash' and 'notice an
expired lease' are literally the same code path. There is no startup recovery
routine to get wrong.
- claim_batch does the SELECT and the UPDATE in one BEGIN IMMEDIATE
transaction. SQLite has no SKIP LOCKED, but with exactly one writer the
claim cannot race: nobody can see a row between the two statements.
- Backpressure is min(max_concurrent_builds - in_flight, disk headroom),
measured with statvfs. A build that cannot fit on disk stays queued instead
of filling the filesystem halfway through a compile.
- Retry policy (§8.4): transient failures (IO, HTTP) requeue up to
max_transient_attempts; a deterministic build failure is never retried, and
the release stays approved_but_unbuilt so the old version never looks
healthy. Tests assert attempt==1 for build-fails and attempt==3 for a
transient one.
- A superseded candidate sets cancel_requested on in-flight builds; the worker
stops at the step boundary rather than mid-step, which is what keeps the
checkpoints honest.
- Publish takes a process-wide lock so two workers cannot interleave the index
rewrite. The critical section is the db file rewrite, never a build.
- The deterministic build id makes re-enqueue an INSERT OR IGNORE no-op, so a
careless 'rebuild that again' is harmless.
tests/dispatch.rs drives the real threads: the pool takes a queued build all
the way to publication, a reaped build resumes from its checkpoints without
re-running makechrootpkg, and backpressure admits exactly one build per slot.
Serve now starts the pool alongside the watcher and the HTTP server.
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index 5bcb5aa..270c81e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -55,6 +55,19 @@ pub struct Config { pub publish_fault: Option<String>, /// Test hook: the named shim must fail, e.g. `makechrootpkg`. pub shim_fail: Option<String>, + /// How many builds may run at once (§8.2 backpressure). Default 1, which + /// also means the chroot pool only needs one warm root. + pub max_concurrent_builds: usize, + /// Seconds of lease a worker takes when it claims a build (§8.2). + pub lease_secs: i64, + /// A build is not admitted unless at least this much free space remains + /// on the filesystem holding `root` (§8.2 disk headroom). + pub min_free_disk_mb: u64, + /// Transient step failures are retried up to this many attempts; a + /// deterministic build failure is never retried (§8.4). + pub max_transient_attempts: i64, + /// Seconds between dispatcher passes. + pub dispatch_tick_secs: u64, } impl Default for Config { @@ -80,6 +93,11 @@ impl Default for Config { shim_dir: None, publish_fault: None, shim_fail: None, + max_concurrent_builds: 1, + lease_secs: 90, + min_free_disk_mb: 1024, + max_transient_attempts: 3, + dispatch_tick_secs: 2, } } } |
