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
5 changes: 3 additions & 2 deletions database/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,16 @@ pub trait Connection: Send + Sync {
commit_date: DateTime<Utc>,
) -> anyhow::Result<()>;

/// Add a benchmark job to the job queue and return its ID.
/// Add a benchmark job to the job queue and returns its ID, if it was not
/// already in the DB previously.
async fn enqueue_benchmark_job(
&self,
request_tag: &str,
target: Target,
backend: CodegenBackend,
profile: Profile,
benchmark_set: u32,
) -> anyhow::Result<u32>;
) -> anyhow::Result<Option<u32>>;

/// Add a benchmark job which is explicitly using a `parent_sha` we split
/// this out to improve our error handling. A `parent_sha` may not have
Expand Down
13 changes: 9 additions & 4 deletions database/src/pool/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1804,10 +1804,11 @@ where
backend: CodegenBackend,
profile: Profile,
benchmark_set: u32,
) -> anyhow::Result<u32> {
let row = self
) -> anyhow::Result<Option<u32>> {
// This will return zero rows if the job already exists
let rows = self
.conn()
.query_one(
.query(
r#"
INSERT INTO job_queue(
request_tag,
Expand All @@ -1832,7 +1833,11 @@ where
)
.await
.context("failed to insert benchmark_job")?;
Ok(row.get::<_, i32>(0) as u32)
if let Some(row) = rows.first() {
return Ok(Some(row.get::<_, i32>(0) as u32));
} else {
return Ok(None);
}
}

async fn get_compile_test_cases_with_measurements(
Expand Down
2 changes: 1 addition & 1 deletion database/src/pool/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ impl Connection for SqliteConnection {
_backend: CodegenBackend,
_profile: Profile,
_benchmark_set: u32,
) -> anyhow::Result<u32> {
) -> anyhow::Result<Option<u32>> {
no_queue_implementation_abort!()
}

Expand Down
2 changes: 1 addition & 1 deletion database/src/tests/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl RequestBuilder {
)
.await
.unwrap();
self.jobs.push((job.clone(), id));
self.jobs.push((job.clone(), id.unwrap()));
}
self
}
Expand Down
Loading