diff --git a/database/src/lib.rs b/database/src/lib.rs index bac85fd55..be409ec13 100644 --- a/database/src/lib.rs +++ b/database/src/lib.rs @@ -1028,7 +1028,7 @@ impl BenchmarkRequest { .split(',') .map(Profile::from_str) .collect::, _>>() - .map_err(|e| anyhow::anyhow!("Invalid backend: {e}")) + .map_err(|e| anyhow::anyhow!("Invalid profile: {e}")) } pub fn is_completed(&self) -> bool { diff --git a/database/src/pool/postgres.rs b/database/src/pool/postgres.rs index 7304123f4..fd855c8d4 100644 --- a/database/src/pool/postgres.rs +++ b/database/src/pool/postgres.rs @@ -1874,9 +1874,9 @@ where .await .context("failed to insert benchmark_job")?; if let Some(row) = rows.first() { - return Ok(Some(row.get::<_, i32>(0) as u32)); + Ok(Some(row.get::<_, i32>(0) as u32)) } else { - return Ok(None); + Ok(None) } } diff --git a/site/src/job_queue/mod.rs b/site/src/job_queue/mod.rs index 13eb61765..badac72a2 100644 --- a/site/src/job_queue/mod.rs +++ b/site/src/job_queue/mod.rs @@ -3,6 +3,7 @@ mod utils; use crate::github::comparison_summary::post_comparison_comment; use crate::job_queue::utils::{parse_release_string, ExtractIf}; use crate::load::{partition_in_place, SiteCtxt}; +use anyhow::Context; use chrono::Utc; use collector::benchmark_set::benchmark_set_count; use database::pool::Transaction; @@ -230,13 +231,14 @@ pub async fn enqueue_benchmark_request( let created_job = tx .conn() .enqueue_benchmark_job(request_tag, target, backend, profile, benchmark_set, kind) - .await?; + .await + .with_context(|| anyhow::anyhow!("Enqueuing job for request {request_tag} (target={target}, backend={backend}, profile={profile}, set={benchmark_set}, kind={kind})"))?; match created_job { - Some(_) => Ok(()), - None => Err(anyhow::anyhow!( - "Cannot created job for tag {request_tag} (target={target}, backend={backend}, profile={profile}, set={benchmark_set}, kind={kind}): job already exists in the DB" - )), - } + Some(_) => Ok(()), + None => Err(anyhow::anyhow!( + "Cannot create job for tag {request_tag} (target={target}, backend={backend}, profile={profile}, set={benchmark_set}, kind={kind}): job already exists in the DB" + )), + } }; // Target x benchmark_set x backend x profile -> BenchmarkJob @@ -284,7 +286,9 @@ pub async fn enqueue_benchmark_request( if is_foreign_key_violation { log::error!("Failed to create job for parent sha {e:?}"); } else { - return Err(e); + return Err(anyhow::anyhow!( + "Cannot enqueue parent benchmark job: {e:?}" + )); } } } @@ -323,8 +327,12 @@ pub async fn enqueue_benchmark_request( tx.conn() .update_benchmark_request_status(request_tag, BenchmarkRequestStatus::InProgress) - .await?; - tx.commit().await?; + .await + .context("Updating benchmark request status to in progress")?; + tx.commit().await.context("Transaction commit")?; + + log::info!("Jobs enqueued"); + Ok(()) } @@ -346,7 +354,11 @@ async fn process_benchmark_requests( match request.status() { BenchmarkRequestStatus::InProgress => { let tag = request.tag().expect("In progress request without a tag"); - if conn.maybe_mark_benchmark_request_as_completed(tag).await? { + if conn + .maybe_mark_benchmark_request_as_completed(tag) + .await + .context("cannot mark benchmark request as completed")? + { log::info!("Request {tag} marked as completed"); completed.push(request); continue; @@ -354,7 +366,9 @@ async fn process_benchmark_requests( break; } BenchmarkRequestStatus::ArtifactsReady => { - enqueue_benchmark_request(conn, &request).await?; + enqueue_benchmark_request(conn, &request) + .await + .context("cannot enqueue benchmark request")?; break; } BenchmarkRequestStatus::WaitingForArtifacts