fix: Entladen erst nach bestätigtem Ende freigeben (#1166); Version 0.1.15-rc18

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmHhg6k5Hxh8GpVW7od4Di
This commit is contained in:
2026-11-20 23:40:00 +01:00
parent 8e76efbfc4
commit 40e0f83b59
6 changed files with 210 additions and 20 deletions

View File

@ -149,6 +149,8 @@ struct Inst {
active: u32,
last_used: Instant,
idle: Option<Duration>,
/// Nach einem gescheiterten Stopp bis dahin weder verdrängen noch im Leerlauf entladen (#1166).
unload_blocked_until: Option<Instant>,
}
/// Sicht auf eine Instanz (für Status und Tests).
@ -298,6 +300,22 @@ impl Planner {
self.plan(now)
}
/// Das Beenden der Instanz ist gescheitert und sie läuft nachweislich weiter: Sie bleibt belegt und
/// bereit, damit ihr Speicher nicht ein zweites Mal vergeben wird. Bis `retry_after` wird sie weder
/// verdrängt noch im Leerlauf entladen (kein enger Wiederholungskreis); ein Entladen von Hand bleibt möglich.
pub fn unload_failed(
&mut self,
inst: InstId,
now: Instant,
retry_after: Duration,
) -> Vec<Action> {
if let Some(i) = self.insts.get_mut(&inst) {
i.state = InstState::Ready;
i.unload_blocked_until = Some(now + retry_after);
}
self.plan(now)
}
/// Die Instanz ist ohne Zutun des Schedulers verschwunden (Absturz).
pub fn lost(&mut self, inst: InstId, now: Instant) -> Vec<Action> {
if self.insts.remove(&inst).is_none() {
@ -356,6 +374,7 @@ impl Planner {
.filter(|(_, i)| {
i.state == InstState::Ready
&& i.active == 0
&& i.unload_blocked_until.is_none_or(|t| now >= t)
&& i.idle
.is_some_and(|d| now.saturating_duration_since(i.last_used) >= d)
&& !self.queue.iter().any(|j| j.need.model == i.model)
@ -523,6 +542,7 @@ impl Planner {
active: 0,
last_used: now,
idle: job.need.idle,
unload_blocked_until: None,
},
);
actions.push(Action::Load {
@ -567,6 +587,7 @@ impl Planner {
.filter(|(_, i)| {
i.state == InstState::Ready
&& i.active == 0
&& i.unload_blocked_until.is_none_or(|t| now >= t)
&& i.gpus.iter().any(|g| gpus.contains(g))
&& (priority == Priority::High
|| now.saturating_duration_since(i.last_used)