diff options
| author | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-19 17:33:17 +0000 |
| commit | 4304b0f336ddba7b4ec6780795059ff2066d105b (patch) | |
| tree | 10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /src/db/builds.rs | |
| parent | e757979f1a2afdbe7146066345bb9acd19d3b151 (diff) | |
| download | aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip | |
comments: keep only what the code cannot show
Stripped every comment that described what an item does, documented its
arguments or fields, or cited the design docs (§n, I-n, m-n, decision n).
2247 comments down to 83.
What survives: the section dividers that segment the large modules, the
secret-handling warnings, the agent wire-frame directions, and the few notes
without which the code they attach to reads as redundant, reorderable, or
unsound.
Diffstat (limited to 'src/db/builds.rs')
| -rw-r--r-- | src/db/builds.rs | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/src/db/builds.rs b/src/db/builds.rs index 8598dd3..de9e7fb 100644 --- a/src/db/builds.rs +++ b/src/db/builds.rs @@ -50,13 +50,10 @@ pub(crate) fn row_to_build(r: &rusqlite::Row<'_>) -> rusqlite::Result<BuildRow> }) } -/// Deterministic build id (§8.2): re-submitting the same intent is a no-op, -/// which is what makes manual rebuilds safe to enqueue carelessly. pub fn build_id(pkgbase: &str, identity_hash: &str, world_hash: &str, profile: &str) -> String { crate::hash::hex_str(&format!("{pkgbase}|{identity_hash}|{world_hash}|{profile}")) } -/// Enqueue a build intent. `INSERT OR IGNORE` on the deterministic id. #[allow(clippy::too_many_arguments)] pub fn enqueue( db: &Db, @@ -130,7 +127,6 @@ pub fn queued(db: &Db, limit: i64) -> Result<Vec<String>> { }) } -/// Claim a build for a worker: the lease is what makes a crash recoverable. pub fn claim(db: &Db, owner: &str, id: &str, lease_secs: i64) -> Result<bool> { let (owner, id) = (owner.to_string(), id.to_string()); let exp = time::secs_ahead(lease_secs); @@ -158,10 +154,6 @@ pub fn extend_lease(db: &Db, id: &str, lease_secs: i64) -> Result<()> { }) } -/// Reaper pass (§8.2): expired leases go back to the queue and their in-flight step -/// is marked interrupted, so the checkpoint decides where it resumes. -/// -/// Both `leased` and `running` are reaped: a mid-step death leaves a `running` row. pub fn reap_expired(db: &Db) -> Result<usize> { let now = time::now(); db.writer.tx(move |tx| { @@ -189,10 +181,6 @@ pub fn reap_expired(db: &Db) -> Result<usize> { }) } -/// The one way a build changes state, usable inside a transaction. -/// -/// The write is a compare-and-swap: only a row in one of `to`'s legal predecessor -/// states is updated, so a zombie worker whose lease was reaped gets an error. fn transition_in_tx( tx: &mut rusqlite::Transaction<'_>, id: &str, @@ -224,7 +212,6 @@ fn transition_in_tx( Ok(()) } -/// Move a build to `to`, refusing any transition [`BuildState`] forbids. pub fn set_state(db: &Db, id: &str, to: BuildState, error: Option<&str>) -> Result<()> { let id = id.to_string(); let error = error.map(|e| e.to_string()); @@ -242,10 +229,6 @@ pub fn block_on(db: &Db, id: &str, blocked_on: &[String]) -> Result<()> { }) } -/// Requeue blocked builds whose blocking packages have since arrived (§10.4). -/// -/// Not "requeue everything that is blocked": the dispatcher calls this every pass, -/// and requeueing a build that will immediately block again burns a claim each tick. pub fn requeue_blocked(db: &Db) -> Result<usize> { let now = time::now(); db.writer.tx(move |tx| { @@ -256,8 +239,6 @@ pub fn requeue_blocked(db: &Db) -> Result<usize> { .collect::<rusqlite::Result<Vec<(String, String)>>>()?; out }; - // The index membership check is one query for the whole pass, not one per - // dependency of every blocked build (m-17), on the dispatcher's hot loop. let in_index: std::collections::HashSet<String> = { let mut stmt = tx.prepare("SELECT name FROM package WHERE state='in_index'")?; let names = stmt @@ -349,9 +330,6 @@ pub fn begin_step(db: &Db, build_id: &str, step: &str, attempt: i64) -> Result<( let (b, s) = (build_id.to_string(), step.to_string()); let at = time::now(); db.writer.tx(move |tx| { - // The `WHERE` is I5 with teeth: a step already checkpointed as done is - // frozen, so a resume that asks to re-run it cannot overwrite the record - // that told it to skip. The insert path is unaffected. let n = tx.execute( "INSERT INTO build_step (build_id, step, status, attempt, started_at) VALUES (?1,?2,'running',?3,?4) @@ -370,8 +348,6 @@ pub fn begin_step(db: &Db, build_id: &str, step: &str, attempt: i64) -> Result<( }) } -/// Record what a step produced. Refuses a transition [`StepState`] forbids — -/// above all, writing over a checkpoint a resume is relying on. pub fn finish_step( db: &Db, build_id: &str, @@ -416,7 +392,6 @@ pub fn finish_step( }) } -/// Builds in flight (leased or running), for the backpressure calculation. pub fn in_flight(db: &Db) -> Result<usize> { db.read(|c| { Ok(c.query_row( @@ -460,7 +435,6 @@ pub fn touch(db: &Db, id: &str) -> Result<()> { }) } -/// Record which release a build produced, inside the publish transaction. pub fn set_release_in(tx: &rusqlite::Transaction<'_>, id: &str, release_id: i64) -> Result<()> { tx.execute("UPDATE build SET release_id=?1 WHERE id=?2", params![release_id, id])?; Ok(()) @@ -532,9 +506,6 @@ pub fn current_state(c: &Connection, id: &str) -> Result<Option<BuildState>> { } } -/// Claim up to `limit` queued builds in one `BEGIN IMMEDIATE` transaction and -/// hand them to workers (§8.2). SQLite has no `SKIP LOCKED`, but with exactly one -/// writer the claim cannot race: the SELECT and the UPDATE are one transaction. pub fn claim_batch(db: &Db, owner: &str, limit: usize, lease_secs: i64) -> Result<Vec<String>> { if limit == 0 { return Ok(Vec::new()); @@ -563,9 +534,6 @@ pub fn claim_batch(db: &Db, owner: &str, limit: usize, lease_secs: i64) -> Resul }) } -/// A newer approved release for the same pkgbase makes an in-flight build -/// pointless (§8.2 cancellation). Workers notice at the next step boundary and -/// stop; nothing is killed mid-step, which is what keeps the checkpoints honest. pub fn cancel_superseded(db: &Db) -> Result<usize> { db.writer.tx(move |tx| { let n = tx.execute( @@ -578,17 +546,12 @@ pub fn cancel_superseded(db: &Db) -> Result<usize> { }) } -/// Put a build back on the queue after a transient failure, keeping the attempt -/// count so the retry cap can bite (§8.4). pub fn requeue_transient(db: &Db, id: &str) -> Result<()> { let id = id.to_string(); db.writer .tx(move |tx| transition_in_tx(tx, &id, BuildState::Queued, None)) } -/// Explicitly retry a failed build (§8.4): the failed step goes back to pending, -/// everything that succeeded stays checkpointed, and the attempt counter keeps -/// counting. pub fn retry(db: &Db, id: &str) -> Result<()> { let id = id.to_string(); db.writer.tx(move |tx| { @@ -597,8 +560,6 @@ pub fn retry(db: &Db, id: &str) -> Result<()> { WHERE build_id=?1 AND status IN ('failed','interrupted')", params![id], )?; - // The move itself goes through the machine, so requeueing a build that - // already published is refused with a reason. transition_in_tx(tx, &id, BuildState::Queued, None)?; tx.execute("UPDATE build SET cancel_requested=0 WHERE id=?1", params![id])?; Ok(()) |
