sched: add startup recovery that never executes work (T10)

This commit is contained in:
lda
2026-09-08 10:46:17 +07:00 Verified
parent d406c1c435
commit 558f0c3e95
3 changed files with 322 additions and 8 deletions
+14 -8
View File
@@ -125,10 +125,15 @@ class Scheduler:
return admission.schedule_id
def _task_load(self) -> int:
from wf_scheduling.recovery import _is_pending
count = 0
for run in self.run_store.list_runs():
if self._status_value(run) == "admitted":
count += 1
if self._status_value(run) != "admitted":
continue
if _is_pending(self.run_store, run.id):
continue
count += 1
return count
def _record(
@@ -374,15 +379,15 @@ class Scheduler:
def _dispatch_pending(self, now: datetime) -> None:
"""Dispatch recovery-materialized runs through capacity checks.
Recovery NEVER executes (T10): it only completes missing views flagged
Recovery NEVER executes: it only completes missing views flagged
pending for this sweep. Pending runs of blocked schedules stay
pending. F11 is descoped to T10 here: the pending-dispatch marker does
not exist yet, so only runs explicitly flagged ``needs_dispatch``
dispatch in this sweep and hanging admitted runs are never
re-executed.
pending. Hanging admitted runs without a pending marker are never
re-executed here.
"""
from wf_scheduling.recovery import _is_pending, clear_pending
for run in sorted(self.run_store.list_runs(), key=lambda r: r.id):
if not getattr(run, "needs_dispatch", False):
if not _is_pending(self.run_store, run.id):
continue
try:
admission = self.run_store.get_admission(run.id)
@@ -399,6 +404,7 @@ class Scheduler:
if self._task_load() >= self.capacity:
continue
self._dispatch(run.id, now)
clear_pending(self.run_store, run.id)
def _poll_one(self, sched: Any, now: datetime) -> str:
if sched.deleted: