From fdd004c50de6131be193044ae40424d691425a81 Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 18:28:16 +0000 Subject: db, watch: two N+1s and a version rule with one owner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit m-17. `watch::staleness::dependents_of` walked the index and asked for each package's recipe by name — one query per package, on the path that runs after every publish, with N equal to the size of the index. `db::index_recipes` returns the whole table in one query now. While there: a recipe that fails to parse is no longer treated as "does not depend on this package". An unreadable srcinfo used to hide a dependent from staleness by returning `None` into an `unwrap_or(false)`; now it is a reason to look. `db::builds::requeue_blocked` asked "is this name in the index?" once per dependency of every blocked build, inside the dispatcher's hot loop. The set of in-index names is read once per pass and tested in memory. Same answer, one query. m-18. `approved_but_unbuilt` assembled the version a human reads with two `CASE WHEN epoch='0'` expressions in SQL — a second, independent copy of the `epoch:pkgver-pkgrel` rule that `pkgver::full_version` owns. Two copies of a formatting rule is how the Attention page ends up describing versions differently from every other page. The query returns the parts; Rust formats them. A guard test fails if version-string concatenation reappears in SQL. --- src/watch/staleness.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/watch') diff --git a/src/watch/staleness.rs b/src/watch/staleness.rs index cc7242c..e052b26 100644 --- a/src/watch/staleness.rs +++ b/src/watch/staleness.rs @@ -102,20 +102,21 @@ pub fn downgrades(db: &Db) -> Result> { /// its recipe dependencies. pub fn dependents_of(db: &Db, name: &str) -> Result> { let mut out: Vec = Vec::new(); - for p in db::index_packages(db)? { - if p.name == name { + for (pkgname, json) in db::index_recipes(db)? { + if pkgname == name { continue; } - let depends = db::recipe_json_of_index_package(db, &p.name)? - .and_then(|j| serde_json::from_str::(&j).ok()) - .map(|r| { - crate::pkgver::dep_names(&r.depends) - .into_iter() - .any(|d| d == name) - }) - .unwrap_or(false); + // A recipe we cannot read is not a recipe that does not depend on + // `name`: treat the unreadable as a reason to look, so a malformed + // srcinfo cannot silently hide a dependent package from staleness. + let depends = match serde_json::from_str::(&json) { + Ok(r) => crate::pkgver::dep_names(&r.depends) + .into_iter() + .any(|d| d == name), + Err(_) => true, + }; if depends { - out.push(p.name); + out.push(pkgname); } } Ok(out) -- cgit v1.2.3