@@ -5,10 +5,10 @@ use crate::selector::CompileTestCase;
55use crate :: {
66 ArtifactCollection , ArtifactId , ArtifactIdNumber , Benchmark , BenchmarkJob ,
77 BenchmarkJobConclusion , BenchmarkJobKind , BenchmarkJobStatus , BenchmarkRequest ,
8- BenchmarkRequestIndex , BenchmarkRequestStatus , BenchmarkRequestType ,
9- BenchmarkRequestWithErrors , BenchmarkSet , CodegenBackend , CollectionId , CollectorConfig ,
10- Commit , CommitType , CompileBenchmark , Date , Index , PendingBenchmarkRequests , Profile ,
11- QueuedCommit , Scenario , Target , BENCHMARK_JOB_STATUS_FAILURE_STR ,
8+ BenchmarkRequestIndex , BenchmarkRequestInsertResult , BenchmarkRequestStatus ,
9+ BenchmarkRequestType , BenchmarkRequestWithErrors , BenchmarkSet , CodegenBackend , CollectionId ,
10+ CollectorConfig , Commit , CommitType , CompileBenchmark , Date , Index , PendingBenchmarkRequests ,
11+ Profile , QueuedCommit , Scenario , Target , BENCHMARK_JOB_STATUS_FAILURE_STR ,
1212 BENCHMARK_JOB_STATUS_IN_PROGRESS_STR , BENCHMARK_JOB_STATUS_QUEUED_STR ,
1313 BENCHMARK_JOB_STATUS_SUCCESS_STR , BENCHMARK_REQUEST_MASTER_STR , BENCHMARK_REQUEST_RELEASE_STR ,
1414 BENCHMARK_REQUEST_STATUS_ARTIFACTS_READY_STR , BENCHMARK_REQUEST_STATUS_COMPLETED_STR ,
@@ -1633,9 +1633,10 @@ where
16331633 async fn insert_benchmark_request (
16341634 & self ,
16351635 benchmark_request : & BenchmarkRequest ,
1636- ) -> anyhow:: Result < ( ) > {
1637- self . conn ( )
1638- . execute (
1636+ ) -> anyhow:: Result < BenchmarkRequestInsertResult > {
1637+ let rows = self
1638+ . conn ( )
1639+ . query (
16391640 r#"
16401641 INSERT INTO benchmark_request(
16411642 tag,
@@ -1648,7 +1649,9 @@ where
16481649 profiles,
16491650 commit_date
16501651 )
1651- VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9);
1652+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
1653+ ON CONFLICT DO NOTHING
1654+ RETURNING id;
16521655 "# ,
16531656 & [
16541657 & benchmark_request. tag ( ) ,
@@ -1664,7 +1667,13 @@ where
16641667 )
16651668 . await
16661669 . context ( "Failed to insert benchmark request" ) ?;
1667- Ok ( ( ) )
1670+ if rows. is_empty ( ) {
1671+ // Allows us to handle duplicated cases without the database auto
1672+ // erroring
1673+ Ok ( BenchmarkRequestInsertResult :: AlreadyQueued )
1674+ } else {
1675+ Ok ( BenchmarkRequestInsertResult :: Queued )
1676+ }
16681677 }
16691678
16701679 async fn load_benchmark_request_index ( & self ) -> anyhow:: Result < BenchmarkRequestIndex > {
0 commit comments