summaryrefslogtreecommitdiffstats
path: root/src/pipeline/dispatch.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pipeline/dispatch.rs')
-rw-r--r--src/pipeline/dispatch.rs39
1 files changed, 8 insertions, 31 deletions
diff --git a/src/pipeline/dispatch.rs b/src/pipeline/dispatch.rs
index 62052fd..d9891c2 100644
--- a/src/pipeline/dispatch.rs
+++ b/src/pipeline/dispatch.rs
@@ -1,21 +1,3 @@
-//! The dispatcher actor, the worker pool and the reaper (§8.2).
-//!
-//! Shape: one dispatcher thread, N worker threads, one crossbeam channel
-//! between them. The dispatcher's loop is
-//!
-//! ```text
-//! reaper: expired leases -> queued, in-flight step -> interrupted
-//! cancel: superseded in-flight builds -> cancel_requested
-//! claim: BEGIN IMMEDIATE { SELECT queued LIMIT admissible; UPDATE leased }
-//! send: build_tx.send(id) for each
-//! ```
-//!
-//! Nothing lives only in a worker's memory. If the process is killed, the lease
-//! expires and the next dispatcher pass puts the build back; the step
-//! checkpoint decides where it resumes (I5). That is the whole crash-recovery
-//! story, and it is why there is no separate "recover on startup" routine — the
-//! reaper pass *is* the recovery, and it runs first in every loop.
-
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread::JoinHandle;
@@ -83,9 +65,8 @@ impl Pool {
}
fn dispatcher(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>, tx: Sender<String>) {
- // The reaper pass runs first on every loop, including the very first one, so
- // "recover from a crash" and "notice an expired lease" are the same code
- // path. There is no special startup recovery to get wrong.
+ // The reaper runs first on every loop, including the first, so "recover from
+ // a crash" and "notice an expired lease" are the same code path.
while !stop.load(Ordering::SeqCst) {
dispatch_once(&cfg, &db, &tx);
let mut slept = 0u64;
@@ -112,7 +93,6 @@ pub fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String>
}
// Blocked builds become eligible again when the blocking package arrives.
let _ = builds::requeue_blocked(db);
- // A newer approval makes an in-flight build pointless (§8.2).
let _ = builds::cancel_superseded(db);
let room = admissible(cfg, db);
@@ -131,10 +111,9 @@ pub fn dispatch_once(cfg: &Config, db: &Db, tx: &Sender<String>) -> Vec<String>
ids
}
-/// How many builds may be admitted right now (§8.2 backpressure):
-/// `min(max_concurrent - in_flight, disk headroom)`. A build that cannot fit on
-/// disk is not admitted — it stays queued rather than filling the filesystem
-/// halfway through a compile.
+/// How many builds may be admitted right now (§8.2 backpressure). A build that
+/// cannot fit on disk stays queued rather than filling the filesystem halfway
+/// through a compile.
pub fn admissible(cfg: &Config, db: &Db) -> usize {
let in_flight = builds::in_flight(db).unwrap_or(0) as usize;
let slots = cfg.max_concurrent_builds.saturating_sub(in_flight);
@@ -176,11 +155,9 @@ fn worker(cfg: Arc<Config>, db: Db, rx: crossbeam_channel::Receiver<String>, sto
let attempt = builds::get(&db, &id).ok().flatten().map(|b| b.attempt).unwrap_or(1);
match pipeline::run(&cfg, &db, &id) {
Ok(Outcome::Failed { transient, .. }) => {
- // §8.4: transient failures (network, mirror 5xx) retry with a
- // bounded number of attempts. A deterministic build failure
- // does NOT retry — the release stays approved_but_unbuilt and
- // the UI says "index still serving v1". Retrying that would burn
- // a chroot to produce the same failure.
+ // §8.4: transient failures retry with a bounded number of
+ // attempts; a deterministic failure does not, because it would
+ // produce the same answer.
if transient && attempt < cfg.max_transient_attempts {
let _ = builds::requeue_transient(&db, &id);
db::audit_system(