From bdb72c8b6348b4bd0a7cbc00ff128971701fb77b Mon Sep 17 00:00:00 2001 From: Tom Solberg Date: Thu, 14 Nov 2024 13:46:30 +0100 Subject: [PATCH] Add information about workunit when failing to backtrack (#21632) I don't think there's much information to be had here, fundamentally, but on the off-chance there is it would be interesting. Relates to: https://github.com/pantsbuild/pants/issues/19748, which we've started seeing quite regularly at work. --- src/rust/engine/src/context.rs | 8 +++++++- src/rust/engine/workunit_store/src/lib.rs | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/rust/engine/src/context.rs b/src/rust/engine/src/context.rs index 209749611a7..7878a85a76f 100644 --- a/src/rust/engine/src/context.rs +++ b/src/rust/engine/src/context.rs @@ -871,8 +871,14 @@ impl SessionCore { } else { // There are no live or invalidated sources of this Digest. Directly fail. return result.map_err(|e| { + let suffix = if let Some(workunit_data) = workunit.workunit() { + &format!(", with workunit: {:?}", workunit_data) + } else { + "" + }; + throw(format!( - "Could not identify a process to backtrack to for: {e}" + "Could not identify a process to backtrack to for: {e}{suffix}" )) }); } diff --git a/src/rust/engine/workunit_store/src/lib.rs b/src/rust/engine/workunit_store/src/lib.rs index f0fabe8b56d..5035a5eccab 100644 --- a/src/rust/engine/workunit_store/src/lib.rs +++ b/src/rust/engine/workunit_store/src/lib.rs @@ -889,6 +889,10 @@ impl RunningWorkunit { } } + pub fn workunit(&self) -> Option<&Workunit> { + self.workunit.as_ref() + } + pub fn record_observation(&self, metric: ObservationMetric, value: u64) { self.store.record_observation(metric, value); }