Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion database/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ impl BenchmarkRequest {
.split(',')
.map(Profile::from_str)
.collect::<Result<Vec<_>, _>>()
.map_err(|e| anyhow::anyhow!("Invalid backend: {e}"))
.map_err(|e| anyhow::anyhow!("Invalid profile: {e}"))
}

pub fn is_completed(&self) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions database/src/pool/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
36 changes: 25 additions & 11 deletions site/src/job_queue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:?}"
));
}
}
}
Expand Down Expand Up @@ -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(())
}

Expand All @@ -346,15 +354,21 @@ 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;
}
break;
}
BenchmarkRequestStatus::ArtifactsReady => {
enqueue_benchmark_request(conn, &request).await?;
enqueue_benchmark_request(conn, &request)
.await
.context("cannot enqueue benchmark request")?;
break;
}
BenchmarkRequestStatus::WaitingForArtifacts
Expand Down
Loading