From 2c5a660213ae5f9f6f12d9787c5195e2c2127e6d Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 08:47:27 +0000 Subject: =?UTF-8?q?pipeline:=20a=20real=20process=20kill,=20and=20the=20fa?= =?UTF-8?q?ilure=20state=20the=20UI=20must=20show=20(=C2=A78.4,=20I5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The crash-resume invariant was only ever simulated before: an in-process fault hook returns an error, and an error can be caught, unwound and cleaned up by accident. So the shims gained AUR_SHIM_KILL_PARENT — the named tool SIGKILLs the process running the pipeline, mid-step, with no Drop and no atexit. The test spawns the real aur-build binary, watches it die of SIGKILL inside the build step, and then asserts the things that matter: - the database is intact, because no transaction ever spans a build step - the completed steps are checkpointed succeeded and the running one is recorded running - after the lease expires the reaper requeues it and marks the step interrupted - resuming publishes exactly one release, and the shim invocation log proves mkarchroot ran once, makechrootpkg twice (crash + resume, not twice per attempt) and repo-add once **This found a real bug.** reap_expired only matched state='leased', but a worker sets state='running' the moment it starts a step, so a process that dies mid-step leaves a running row — and every real crash would have been stranded forever. The reaper now reaps leased and running. Also §8.4's other half, which was a comment rather than a feature: a failed build must not leave the old version looking healthy. db::approved_but_unbuilt finds approvals whose build failed and never published, and Attention and the package page now say 'v2 approved, build failed, index still serving v1' with a link to the log. Retrying is an explicit, audited POST, not something the system does to itself. Cancellation is asserted to be cooperative at a step boundary: a cancelled build runs no steps, publishes nothing, and is not counted as a failure. --- src/db/queries.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/db/queries.rs') diff --git a/src/db/queries.rs b/src/db/queries.rs index 3adc92f..fa530b4 100644 --- a/src/db/queries.rs +++ b/src/db/queries.rs @@ -951,3 +951,55 @@ pub fn index_pkgbase_drift(db: &Db) -> Result<(Vec, Vec)> { Ok((orphans, missing)) }) } + +/// An approved change whose build failed and which therefore never reached the +/// index (§8.4). This is the state that must never look healthy: a human said +/// yes, the build died, and the index is quietly still serving the previous +/// version. Surfacing it is the whole point of `approved_but_unbuilt`. +#[derive(Debug, Clone)] +pub struct Unbuilt { + pub pkgbase: String, + /// The version that was approved but never published. + pub approved: String, + /// The version the index actually serves, empty if nothing is served. + pub serving: String, + pub error: String, + pub build_id: String, +} + +pub fn approved_but_unbuilt(db: &Db) -> Result> { + db.read(|c| { + let mut stmt = c.prepare( + "SELECT p.name, + (SELECT (CASE WHEN c.epoch='0' THEN '' ELSE c.epoch||':' END) || c.pkgver || '-' || c.pkgrel + FROM candidate c WHERE c.id = b.candidate_id), + COALESCE((SELECT (CASE WHEN r.epoch='0' THEN '' ELSE r.epoch||':' END) || r.pkgver || '-' || r.pkgrel + FROM release r JOIN pkgbase pb ON pb.current_accepted_release_id = r.id + WHERE pb.id = p.id AND r.state='published'), ''), + COALESCE(b.error, ''), b.id + FROM build b + JOIN pkgbase p ON p.id = b.pkgbase_id + WHERE b.state = 'failed' + AND b.candidate_id IS NOT NULL + AND NOT EXISTS (SELECT 1 FROM release r WHERE r.candidate_id = b.candidate_id) + AND b.id = (SELECT b2.id FROM build b2 + WHERE b2.candidate_id = b.candidate_id + ORDER BY b2.rowid DESC LIMIT 1) + ORDER BY p.name", + )?; + let rows = stmt.query_map([], |r| { + Ok(Unbuilt { + pkgbase: r.get(0)?, + approved: r.get(1)?, + serving: r.get(2)?, + error: r.get(3)?, + build_id: r.get(4)?, + }) + })?; + let mut out = Vec::new(); + for r in rows { + out.push(r?); + } + Ok(out) + }) +} -- cgit v1.2.3