Skip to content

Commit bb8ffa4

Browse files
committed
Add more error logs
1 parent 9fc23ba commit bb8ffa4

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

database/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ impl BenchmarkRequest {
10281028
.split(',')
10291029
.map(Profile::from_str)
10301030
.collect::<Result<Vec<_>, _>>()
1031-
.map_err(|e| anyhow::anyhow!("Invalid backend: {e}"))
1031+
.map_err(|e| anyhow::anyhow!("Invalid profile: {e}"))
10321032
}
10331033

10341034
pub fn is_completed(&self) -> bool {

database/src/pool/postgres.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,9 +1874,9 @@ where
18741874
.await
18751875
.context("failed to insert benchmark_job")?;
18761876
if let Some(row) = rows.first() {
1877-
return Ok(Some(row.get::<_, i32>(0) as u32));
1877+
Ok(Some(row.get::<_, i32>(0) as u32))
18781878
} else {
1879-
return Ok(None);
1879+
Ok(None)
18801880
}
18811881
}
18821882

site/src/job_queue/mod.rs

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod utils;
33
use crate::github::comparison_summary::post_comparison_comment;
44
use crate::job_queue::utils::{parse_release_string, ExtractIf};
55
use crate::load::{partition_in_place, SiteCtxt};
6+
use anyhow::Context;
67
use chrono::Utc;
78
use collector::benchmark_set::benchmark_set_count;
89
use database::pool::Transaction;
@@ -230,13 +231,14 @@ pub async fn enqueue_benchmark_request(
230231
let created_job = tx
231232
.conn()
232233
.enqueue_benchmark_job(request_tag, target, backend, profile, benchmark_set, kind)
233-
.await?;
234+
.await
235+
.with_context(|| anyhow::anyhow!("Enqueuing job for request {request_tag} (target={target}, backend={backend}, profile={profile}, set={benchmark_set}, kind={kind})"))?;
234236
match created_job {
235-
Some(_) => Ok(()),
236-
None => Err(anyhow::anyhow!(
237-
"Cannot created job for tag {request_tag} (target={target}, backend={backend}, profile={profile}, set={benchmark_set}, kind={kind}): job already exists in the DB"
238-
)),
239-
}
237+
Some(_) => Ok(()),
238+
None => Err(anyhow::anyhow!(
239+
"Cannot create job for tag {request_tag} (target={target}, backend={backend}, profile={profile}, set={benchmark_set}, kind={kind}): job already exists in the DB"
240+
)),
241+
}
240242
};
241243

242244
// Target x benchmark_set x backend x profile -> BenchmarkJob
@@ -284,7 +286,9 @@ pub async fn enqueue_benchmark_request(
284286
if is_foreign_key_violation {
285287
log::error!("Failed to create job for parent sha {e:?}");
286288
} else {
287-
return Err(e);
289+
return Err(anyhow::anyhow!(
290+
"Cannot enqueue parent benchmark job: {e:?}"
291+
));
288292
}
289293
}
290294
}
@@ -323,8 +327,12 @@ pub async fn enqueue_benchmark_request(
323327

324328
tx.conn()
325329
.update_benchmark_request_status(request_tag, BenchmarkRequestStatus::InProgress)
326-
.await?;
327-
tx.commit().await?;
330+
.await
331+
.context("Updating benchmark request status to in progress")?;
332+
tx.commit().await.context("Transaction commit")?;
333+
334+
log::info!("Jobs enqueued");
335+
328336
Ok(())
329337
}
330338

@@ -346,15 +354,21 @@ async fn process_benchmark_requests(
346354
match request.status() {
347355
BenchmarkRequestStatus::InProgress => {
348356
let tag = request.tag().expect("In progress request without a tag");
349-
if conn.maybe_mark_benchmark_request_as_completed(tag).await? {
357+
if conn
358+
.maybe_mark_benchmark_request_as_completed(tag)
359+
.await
360+
.context("cannot mark benchmark request as completed")?
361+
{
350362
log::info!("Request {tag} marked as completed");
351363
completed.push(request);
352364
continue;
353365
}
354366
break;
355367
}
356368
BenchmarkRequestStatus::ArtifactsReady => {
357-
enqueue_benchmark_request(conn, &request).await?;
369+
enqueue_benchmark_request(conn, &request)
370+
.await
371+
.context("cannot enqueue benchmark request")?;
358372
break;
359373
}
360374
BenchmarkRequestStatus::WaitingForArtifacts

0 commit comments

Comments
 (0)