Skip to content

Commit c1be8d2

Browse files
Fix marking experiment crates as complete
When processing GitHub repositories, our list usually (always?) contains a repository without any form of commit hash. Crater agents checkout that repository and, as part of building it, record the commit hash they used. The agent then submits that hash to the db for storage. When storing the hash, we *replace* the "crate name" (owner.reponame) with a more specific ID (e.g., owner.reponame.$cratehash). This means that the set of crates we tested has effectively *changed* at this point from our perspective. Next we store results (previously under the original name, now under the new name) and also update the (previous old, now new) experiment_crates record to mark it complete. The net effect is that prior to this commit (and likely since ~Aug 31) every GitHub repository has been repeatedly tested by Crater until we eventually hit count(results) >= count(experiment_crates). This is basically just a random point in time though, AFAICT there's no relationship between the set of crates we wanted to test and the set of results we have. One saving factor is there's some amount of fixed point -- if the GitHub repository we test doesn't receive any new commits between attempts to run it, we'll re-test the same code and the old/new IDs will match, letting us mark it as complete. But this is at best a minor improvement, it's not actually a mitigating factor. As a future TODO, we probably should update the "finish condition" from counting results and experiment_crates and instead use something like "are there any experiment_crates with a status of queued" which makes much more sense.
1 parent d67f575 commit c1be8d2

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/results/db.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,31 @@ impl<'a> DatabaseDB<'a> {
8383
data: &ProgressData,
8484
encoding_type: EncodingType,
8585
) -> Fallible<()> {
86+
let krate = if let Some((old, new)) = &data.version {
87+
// If we're updating the name of the crate (typically changing the hash we found on
88+
// github) then we ought to also use that new name for marking the crate as complete.
89+
// Otherwise, we leave behind the old (unversioned) name and end up running this crate
90+
// many times, effectively never actually completing it.
91+
self.update_crate_version(ex, old, new)?;
92+
93+
// sanity check that the previous name of the crate is the one we intended to run.
94+
if old.id() != data.result.krate.id() {
95+
log::warn!(
96+
"Storing result under {} despite job intended for {} (with wrong name old={})",
97+
new.id(),
98+
data.result.krate.id(),
99+
old.id(),
100+
);
101+
}
102+
103+
new
104+
} else {
105+
&data.result.krate
106+
};
107+
86108
self.store_result(
87109
ex,
88-
&data.result.krate,
110+
&krate,
89111
&data.result.toolchain,
90112
&data.result.result,
91113
&base64::engine::general_purpose::STANDARD
@@ -94,11 +116,7 @@ impl<'a> DatabaseDB<'a> {
94116
encoding_type,
95117
)?;
96118

97-
if let Some((old, new)) = &data.version {
98-
self.update_crate_version(ex, old, new)?;
99-
}
100-
101-
self.mark_crate_as_completed(ex, &data.result.krate)?;
119+
self.mark_crate_as_completed(ex, &krate)?;
102120

103121
Ok(())
104122
}

0 commit comments

Comments
 (0)