Skip to content

Commit 8aca666

Browse files
committed
Add a purge_artifact command to manually remove all data of an artifact
1 parent a3db9b9 commit 8aca666

File tree

3 files changed

+40
-21
lines changed

3 files changed

+40
-21
lines changed

collector/src/bin/collector.rs

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

571571
/// Download a crate into collector/benchmarks.
572572
Download(DownloadCommand),
573+
574+
/// Removes all data associated with artifact(s) with the given name.
575+
PurgeArtifact {
576+
/// Name of the artifact.
577+
name: String,
578+
579+
#[command(flatten)]
580+
db: DbOption,
581+
},
573582
}
574583

575584
#[derive(Debug, clap::Parser)]
@@ -953,6 +962,14 @@ fn main_result() -> anyhow::Result<i32> {
953962
println!("Benchmark stored at {}", target_dir.display());
954963
Ok(0)
955964
}
965+
Commands::PurgeArtifact { name, db } => {
966+
let pool = Pool::open(&db.db);
967+
let conn = rt.block_on(pool.connection());
968+
rt.block_on(conn.purge_artifact(&ArtifactId::Tag(name.clone())));
969+
970+
println!("Data of artifact {name} were removed");
971+
Ok(0)
972+
}
956973
}
957974
}
958975

database/manual-modifications.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Useful queries and commands
2+
This document contains useful queries and commands that should be performed manually in exceptional
3+
situations.
4+
5+
## Remove data for an artifact from the DB
6+
This is important for situations where there is some compilation error for a stable benchmark,
7+
with a stable release of the compiler. While this should be rare, it happens sometimes e.g. because
8+
of future incompatibility lints turning into errors.
9+
10+
First, the benchmark should be fixed, and then any data for (published) artifacts that were
11+
benchmarked with the broken benchmark should be removed.
12+
13+
All data associated with an artifact can be removed using the following command:
14+
```bash
15+
$ cargo run --bin collector purge_artifact <artifact-name>
16+
```
17+
18+
Here is an example to remove the data of the `1.70.0` stable release artifact:
19+
```bash
20+
$ cargo run --bin collector purge_artifact 1.70.0
21+
```
22+
23+
After executing this command, the server should automatically re-benchmark the affected artifacts again.

database/queries.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)