Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Keep a verified live Desktop backend after watchdog recovery (#16470)

Daniel Hanadfaf3c33630
diff --git a/studio/src-tauri/src/commands.rs b/studio/src-tauri/src/commands.rs
index f781326747d..bb3414a30a5 100644
--- a/studio/src-tauri/src/commands.rs
+++ b/studio/src-tauri/src/commands.rs
@@ -58,10 +58,9 @@ fn adopted_failure_is_a_stall(verified: bool, served_alive: bool, different_owne
!verified && served_alive && !different_owner
}
-/// Not `alive && inference_active`: a saturated adopted backend fails ownership re-verification,
-/// but its pre-probe busy marker is still evidence that it is generating.
+/// Keep busy stalls when ownership cannot be reverified; any verified live answer wins.
fn watchdog_confirm_keeps_backend(confirmed: &BackendLiveness) -> bool {
- confirmed.inference_active && (confirmed.alive || confirmed.probe_timed_out)
+ confirmed.alive || (confirmed.inference_active && confirmed.probe_timed_out)
}
/// One long last-chance probe before a kill, for a generation that started between probes.
@@ -2147,7 +2146,7 @@ mod tests {
},
false,
);
- assert!(!super::watchdog_confirm_keeps_backend(&idle));
+ assert!(super::watchdog_confirm_keeps_backend(&idle));
let taken_over = super::adopted_backend_liveness(false, &served, true);
assert!(!super::watchdog_confirm_keeps_backend(&taken_over));
@@ -2276,15 +2275,27 @@ mod tests {
.copied()
.unwrap_or(Probe::TimedOut);
next_confirm += 1;
- match confirm {
- Probe::Answered { busy: true, .. } => {
- was_generating = true;
- failures = 0;
- continue;
+ let confirmed = match confirm {
+ Probe::Answered { warming, busy } => super::BackendLiveness {
+ alive: true,
+ warming_up: warming,
+ inference_active: busy,
+ probe_timed_out: false,
+ answered: true,
+ },
+ Probe::TimedOut => {
+ elapsed += confirm_budget;
+ super::BackendLiveness {
+ probe_timed_out: true,
+ ..Default::default()
+ }
}
- Probe::Answered { busy: false, .. } => {}
- Probe::TimedOut => elapsed += confirm_budget,
- Probe::Refused => {}
+ Probe::Refused => super::BackendLiveness::default(),
+ };
+ if super::watchdog_confirm_keeps_backend(&confirmed) {
+ was_generating = confirmed.inference_active;
+ failures = 0;
+ continue;
}
}
if failures >= budget {
@@ -2346,13 +2357,20 @@ mod tests {
),
None
);
+
+ let mut idle_confirmed = vec![answered(false)];
+ idle_confirmed.extend(vec![Probe::TimedOut; plain * 2]);
+ assert_eq!(
+ simulate_watchdog(&idle_confirmed, &[answered(false), Probe::TimedOut]),
+ Some(interval + (plain * 2) as u64 * stall_cycle + confirm_budget)
+ );
assert_eq!(
simulate_watchdog(&started_between_probes, &[Probe::TimedOut]),
Some(interval + plain as u64 * stall_cycle + confirm_budget)
);
assert_eq!(
simulate_watchdog(&started_between_probes, &[answered(false)]),
- Some(interval + plain as u64 * stall_cycle)
+ Some(interval + (plain * 2) as u64 * stall_cycle + confirm_budget)
);
let mut finished = vec![answered(true), answered(false)];
@@ -2640,8 +2658,6 @@ async fn health_watchdog(
budget,
liveness.probe_timed_out,
) {
- // Before killing, one wider probe; only a backend reporting it is generating gets the
- // count reset.
let confirmed = check_watchdog_health(
&state,
generation,
@@ -2652,7 +2668,7 @@ async fn health_watchdog(
.await;
if watchdog_confirm_keeps_backend(&confirmed) {
warn!(
- "Health watchdog: backend on port {} answered the last-chance probe and is still generating, not declaring it dead",
+ "Health watchdog: backend on port {} survived the last-chance probe, not declaring it dead",
port
);
has_seen_healthy = watchdog_seen_healthy_after(
@@ -2660,7 +2676,7 @@ async fn health_watchdog(
confirmed.alive,
confirmed.warming_up,
);
- was_generating = true;
+ was_generating = confirmed.inference_active;
consecutive_failures = 0;
continue;
}