Skip to content

Commit b38e9e2

Browse files
committed
Add a purge_artifact command to manually remove all data of an artifact
1 parent ea867d6 commit b38e9e2

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

collector/src/bin/collector.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,15 @@ enum Commands {
552552

553553
/// Download a crate into collector/benchmarks.
554554
Download(DownloadCommand),
555+
556+
/// Removes all data associated with artifact(s) with the given name.
557+
PurgeArtifact {
558+
/// Name of the artifact.
559+
name: String,
560+
561+
#[command(flatten)]
562+
db: DbOption,
563+
},
555564
}
556565

557566
#[derive(Debug, clap::Parser)]
@@ -1057,6 +1066,14 @@ Make sure to modify `{dir}/perf-config.json` if the category/artifact don't matc
10571066
);
10581067
Ok(0)
10591068
}
1069+
Commands::PurgeArtifact { name, db } => {
1070+
let pool = Pool::open(&db.db);
1071+
let conn = rt.block_on(pool.connection());
1072+
rt.block_on(conn.purge_artifact(&ArtifactId::Tag(name.clone())));
1073+
1074+
println!("Data of artifact {name} were removed");
1075+
Ok(0)
1076+
}
10601077
}
10611078
}
10621079

database/queries.md renamed to database/manual-modifications.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# Useful queries
2-
This document contains useful queries that should be performed manually in exceptional situations.
1+
# Useful queries and commands
2+
This document contains useful queries and commands that should be performed manually in exceptional
3+
situations.
34

45
## Remove data for a stable artifact from the DB
56
This is important for situations where there is some compilation error for a stable benchmark,
@@ -8,9 +9,16 @@ of future incompatibility lints turning into errors.
89

910
The benchmark should be fixed first, and then the DB should be altered (see below).
1011

11-
The easiest solution is to simply completely remove the artifact from the DB. There are
12-
`ON DELETE CASCADE` clauses for `aid` (artifact ID) on tables that reference it, so it should be
13-
enough to just delete the artifact from the `artifact` table.
12+
The easiest solution is to simply completely remove the artifact from the DB.
13+
You can do that either using the following command:
14+
15+
```bash
16+
$ cargo run --bin collector purge_artifact <artifact-name>
17+
# $ cargo run --bin collector purge_artifact 1.70.0 # Remove stable artifact 1.70.0
18+
```
19+
20+
Or using SQL queries. There are `ON DELETE CASCADE` clauses for `aid` (artifact ID) on tables that
21+
reference it, so it should be enough to just delete the artifact from the `artifact` table.
1422
The set of queries below show an example of removing the measured data and errors for Rust `1.69`
1523
and `1.70`:
1624
```sql

0 commit comments

Comments
 (0)