Skip to content

Commit b7a29ff

Browse files
committed
Auto merge of #515 - pietroalbini:fix-agent-hanging, r=pietroalbini
Handle skipped crates added after experiment creation Before this PR, if a new crate was added to the blacklist after an experiment was created a deadlock occured: 1. During experiment creation, the crate is added to the list of crates test during such experiment. 2. The crate is blacklisted, and the server is restarted to apply the blacklist change. 3. The experiment starts running. 4. An agent asks for crates to test during an experiment, and receives the blacklisted crate. 5. The agent ignores the blacklisted crate as it's blacklisted, and replies "I'm done" to the server without actually recording any result for the skipped crate. 6. The server readds the blacklisted crate to the queue for that agent, as it thinks that crate has to be tested and the agent didn't do it. This PR fixes the deadlock by adding a new "Skip" task to the graph, which sends a "skipped" result for blacklisted crates to the server instead of silently ignoring them.
2 parents f991050 + 19b7680 commit b7a29ff

File tree

5 files changed

+49
-2
lines changed

5 files changed

+49
-2
lines changed

src/report/html.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ impl ResultColor for TestResult {
4242
TestResult::TestFail(_) => Color::Single("#65461e"),
4343
TestResult::TestSkipped | TestResult::TestPass => Color::Single("#62a156"),
4444
TestResult::Error => Color::Single("#d77026"),
45+
TestResult::Skipped => Color::Single("#494b4a"),
4546
}
4647
}
4748
}
@@ -81,6 +82,7 @@ impl ResultName for TestResult {
8182
TestResult::TestSkipped => "test skipped".into(),
8283
TestResult::TestPass => "test passed".into(),
8384
TestResult::Error => "error".into(),
85+
TestResult::Skipped => "skipped".into(),
8486
}
8587
}
8688
}

src/report/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ fn compare(
391391
| (TestFail(_), BuildFail(_)) => Comparison::Regressed,
392392

393393
(Error, _) | (_, Error) => Comparison::Error,
394+
(Skipped, _) | (_, Skipped) => Comparison::Skipped,
394395
(BrokenCrate(_), _) | (_, BrokenCrate(_)) => Comparison::Broken,
395396
(TestFail(_), TestSkipped)
396397
| (TestPass, TestSkipped)
@@ -687,6 +688,18 @@ mod tests {
687688
TestFail(Unknown), Error => Error;
688689
BuildFail(Unknown), Error => Error;
689690

691+
// Skipped
692+
Skipped, Skipped => Skipped;
693+
Skipped, TestPass => Skipped;
694+
Skipped, TestSkipped => Skipped;
695+
Skipped, TestFail(Unknown) => Skipped;
696+
Skipped, BuildFail(Unknown) => Skipped;
697+
TestPass, Skipped => Skipped;
698+
TestSkipped, Skipped => Skipped;
699+
TestFail(Unknown), Skipped => Skipped;
700+
BuildFail(Unknown), Skipped => Skipped;
701+
702+
690703
// Broken
691704
BrokenCrate(BrokenReason::Unknown), TestPass => Broken;
692705
BrokenCrate(BrokenReason::Unknown), TestSkipped => Broken;

src/results/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ test_result_enum!(pub enum TestResult {
200200
without_reason {
201201
TestSkipped => "test-skipped",
202202
TestPass => "test-pass",
203+
Skipped => "skipped",
203204
Error => "error",
204205
}
205206
});

src/runner/graph.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,16 @@ pub(super) fn build_graph(ex: &Experiment, crates: &[Crate], config: &Config) ->
260260

261261
for krate in crates {
262262
if !ex.ignore_blacklist && config.should_skip(krate) {
263+
for tc in &ex.toolchains {
264+
let id = graph.add_task(
265+
Task {
266+
krate: krate.clone(),
267+
step: TaskStep::Skip { tc: tc.clone() },
268+
},
269+
&[],
270+
);
271+
graph.add_crate(&[id]);
272+
}
263273
continue;
264274
}
265275

src/runner/tasks.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl<'ctx, DB: WriteResults + 'ctx> TaskCtx<'ctx, DB> {
5151
pub(super) enum TaskStep {
5252
Prepare,
5353
Cleanup,
54+
Skip { tc: Toolchain },
5455
BuildAndTest { tc: Toolchain, quiet: bool },
5556
BuildOnly { tc: Toolchain, quiet: bool },
5657
CheckOnly { tc: Toolchain, quiet: bool },
@@ -64,6 +65,7 @@ impl fmt::Debug for TaskStep {
6465
let (name, quiet, tc) = match *self {
6566
TaskStep::Prepare => ("prepare", false, None),
6667
TaskStep::Cleanup => ("cleanup", false, None),
68+
TaskStep::Skip { ref tc } => ("skip", false, Some(tc)),
6769
TaskStep::BuildAndTest { ref tc, quiet } => ("build and test", quiet, Some(tc)),
6870
TaskStep::BuildOnly { ref tc, quiet } => ("build", quiet, Some(tc)),
6971
TaskStep::CheckOnly { ref tc, quiet } => ("check", quiet, Some(tc)),
@@ -105,7 +107,8 @@ impl Task {
105107
// runner will not reach the prepare task in that case.
106108
TaskStep::Prepare => true,
107109
// Build tasks should only be executed if there are no results for them
108-
TaskStep::BuildAndTest { ref tc, .. }
110+
TaskStep::Skip { ref tc }
111+
| TaskStep::BuildAndTest { ref tc, .. }
109112
| TaskStep::BuildOnly { ref tc, .. }
110113
| TaskStep::CheckOnly { ref tc, .. }
111114
| TaskStep::Clippy { ref tc, .. }
@@ -127,7 +130,8 @@ impl Task {
127130
) -> Fallible<()> {
128131
match self.step {
129132
TaskStep::Prepare | TaskStep::Cleanup => {}
130-
TaskStep::BuildAndTest { ref tc, .. }
133+
TaskStep::Skip { ref tc }
134+
| TaskStep::BuildAndTest { ref tc, .. }
131135
| TaskStep::BuildOnly { ref tc, .. }
132136
| TaskStep::CheckOnly { ref tc, .. }
133137
| TaskStep::Clippy { ref tc, .. }
@@ -221,6 +225,23 @@ impl Task {
221225
crate::runner::unstable_features::find_unstable_features,
222226
)?;
223227
}
228+
TaskStep::Skip { ref tc } => {
229+
// If a skipped crate is somehow sent to the agent (for example, when a crate was
230+
// added to the experiment and *then* blacklisted) report the crate as skipped
231+
// instead of silently ignoring it.
232+
db.record_result(
233+
ex,
234+
tc,
235+
&self.krate,
236+
None,
237+
config,
238+
EncodingType::Plain,
239+
|| {
240+
warn!("crate skipped");
241+
Ok(TestResult::Skipped)
242+
},
243+
)?;
244+
}
224245
}
225246

226247
Ok(())

0 commit comments

Comments
 (0)