fix(scheduler): re-derive worker/shared resource used-totals on snapshot load

xce_sched_core_load_snapshot() left every restored worker's resInUse
(and core->sharedInUse) at zero -- zarray_init() in the workers-
restoration block clears them, and nothing re-summed against the
restored job allocations. A caller inspecting worker/resource state
between a snapshot load and the first scheduling session (e.g. the
REPL's `info worker` before the first `step`) saw a misleadingly empty
"used" total for jobs already known to be RUNNING. Added one
sched_account_jobs(core) call after workers/jobs are restored -- a
correct idempotent-from-zero re-derivation using the same
sched_charge_account() chain the next real session would use anyway.
Must not be called again without an intervening reset (accumulates,
does not assign) -- verified no such double-call exists in this change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QxaSzHRB7pmYFp4cVnwkA
This commit is contained in:
Rongsong Shen 2026-08-29 11:53:32 +00:00
parent 42fdeb6669
commit 14f95b06fe
No known key found for this signature in database
GPG key ID: 5BCDAAE0123E9FE2
5 changed files with 309 additions and 48 deletions

View file

@ -81,6 +81,20 @@ void kill_sched_resval(xce_val_t* val) { (void)val; }
* xce_sched_core_init()'s kvmgr datakiller. */
void plugin_unregister(void* arg) { (void)arg; }
/* xce_sched_core_load_snapshot()'s (snapshot_load.c) linker dependency as
* of scheduler-snapshot-job-allocation task 4.6 -- scheduler.c is
* deliberately not linked here (this file never drives a real scheduling
* session, see this file's own header comment), so a trivial no-op
* satisfies the link. Behaviorally exact, not just link-satisfying: every
* fixture in this file (write_valid_fixture()) snapshots a scheduler with
* zero jobs ever pushed, so the real sched_account_jobs() would iterate
* zero RUN-state jobs and charge nothing here regardless. */
int sched_account_jobs(xce_sched_core_t* core)
{
(void)core;
return 0;
}
/* Real reimplementation of schedobj.c's sched_resolve_job_picker -- same
* rationale/algorithm as test_record_lifecycle.c's own copy (schedobj.c is
* not linked). Both the FIXTURE core (built via a real xce_scheduler_t,