diff --git a/.wolf/buglog.json b/.wolf/buglog.json index 50d1090f..e4f22670 100644 --- a/.wolf/buglog.json +++ b/.wolf/buglog.json @@ -16524,9 +16524,9 @@ }, { "id": "bug-1892", - "status": "open", - "status_updated": "2026-09-30", - "status_note": "newly logged", + "status": "fixed", + "status_updated": "2026-10-01", + "status_note": "", "component": "scheduler", "severity": "wrong-result", "timestamp": "2026-09-30T03:58:52Z", @@ -16534,8 +16534,8 @@ "occurrences": 1, "error_message": "xce_scheduler admission check reads per-resource uncommitted amounts by list position, not index\n\n**Observed:** found by code reading, so there is no failing run yet. `unsatisfy_()` (`src/scheduler/src/resource.c:130-169`) compares\n```c\nif (total[i] < inuse[i] + uncomitted[i] + wanted[i])\n```\nwhere `total`, `inuse` and `wanted` are *positional* arrays (entry `i` is the\n`i`-th resource of the request, gathered by `get_resvals(..., wanted->idxs, ...)`),\nbut `uncomitted` is the context's *dense, resource-index-keyed* vector\n(`ctx->uncomitted.shared` / `ctx->uncomitted.hosts[w]`, 1024 floats,\n`schedobj.c:514/595`), filled by `xvec_idval(uncomit, &req, XVEC_ADD_FLOAT)`,\nwhich writes `d[idx] += val` (`lib/xvec.c`, `DEFINE_XVEC_IDVAL_OP`). Both\n`sched_check_shared_satisfy_()` (`resource.c:309`) and\n`sched_check_host_satisfy_()` (`resource.c:376`) pass `uncomitted->data`\nstraight through, so entry `i` reads the uncommitted amount of resource index\n`i`, not of resource `wanted->idxs[i]`.\n\n**Expected:** entry `i` uses `uncomitted[wanted->idxs[i]]` (gather it\npositionally like `total`/`inuse`, e.g. with the existing `get_resvals()`).\n\n**Impact:** wrong admission result. Uncommitted amounts are nonzero only\nwithin one allocation context that already committed something, i.e. from the\nsecond primary of a COMPOUND (or ALTER) job on, since those primaries share one\n`ctx` (`scheduler.c:348-354`); the first primary and ordinary PRIMARY jobs\nalways see all-zero uncommitted vectors, and parjob rolls back failed plans.\nFor a later primary, the check subtracts an unrelated resource's uncommitted\namount (or 0) instead of the earlier primaries' real claim on the same\nresource, so it can over-admit (earlier primary's claim ignored: the job is\ndispatched beyond host/shared capacity) or wrongly pend (another resource's\namount charged). Pend reasons printed for the same check carry the wrong\nshortfall.\n\n**Found by:** review of the `scheduler-allocator-runner` requirements\n(2026-09-29), while checking the shared-resource precheck the runner inherits.", "file": "src/scheduler/src/resource.c, src/lib/xvec.c", - "root_cause": "TODO: required for fixed/partial", - "fix": "TODO: required for fixed/partial\n\nVerification:\n- Test: TODO: name + file; RED before the fix, GREEN after\n- Suites: TODO: suite results and build profile\n- Live: TODO: soak/deploy run, or n/a and why", + "root_cause": "`unsatisfy_()` (`src/scheduler/src/resource.c`) indexed the uncommitted vector positionally (`uncomitted[i]`) like `total`/`inuse`/`wanted`, but both callers, `sched_check_shared_satisfy_()` and `sched_check_host_satisfy_()`, pass the allocation context's dense vector keyed by resource index (`ctx->uncomitted.shared` / `.hosts[w]`, 1024 floats, filled with `xvec_idval()`). Entry `i` therefore read the uncommitted amount of resource index `i` instead of `wanted->idxs[i]`. It matters from the second primary of a COMPOUND/ALTER job on, the only place a context holds nonzero uncommitted amounts.", + "fix": "`unsatisfy_()` takes the uncommitted `xvec_t*` and reads it through a new `uncomit_at_(uncomitted, wanted->idxs[i])`, which returns 0 for a NULL vector, a negative index, or an index past the vector's end. The last case is needed because `sim_loop.c`'s reconcile checks pass a short all-zero vector sized to the request; reading it by resource index would otherwise run past its end.\n\nVerification:\n- Test: `test_host_satisfy_counts_uncommitted_of_the_wanted_resource` RED (\"Expected 0 Was 1\": over-admit), `test_host_satisfy_ignores_uncommitted_of_another_resource` RED (\"Expected 1 Was 0\": wrong pend), `test_shared_satisfy_counts_uncommitted_of_the_wanted_resource` RED (\"Expected 0 Was 1\"), all GREEN after; `test_host_satisfy_short_uncommitted_vector_counts_as_zero` (guards the bounds check, passes before and after), all in testsuite/test_resource_accounting.c.\n- Suites: scheduler ASAN suite 97/97 (build.alloc), 2026-10-01.\n- Live: n/a for HA (no HA path touched). Sanity: the bug-1897 replay (`--sim`) still completes, exit 0, no ASan report.", "tags": [ "scheduler", "allocation", @@ -16545,7 +16545,9 @@ "related_bugs": [ "bug-1893" ], - "fix_commits": [], + "fix_commits": [ + "e822b888" + ], "record": ".wolf/bugs/bug-1892.md" }, { diff --git a/.wolf/bugs/bug-1892.md b/.wolf/bugs/bug-1892.md index 3551a5f4..bcb2013b 100644 --- a/.wolf/bugs/bug-1892.md +++ b/.wolf/bugs/bug-1892.md @@ -1,8 +1,8 @@ --- id: "bug-1892" -status: "open" -status_updated: "2026-09-30" -status_note: "newly logged" +status: "fixed" +status_updated: "2026-10-01" +status_note: "" component: "scheduler" severity: "wrong-result" timestamp: "2026-09-30T03:58:52Z" @@ -11,6 +11,7 @@ occurrences: 1 files: ["src/scheduler/src/resource.c", "src/lib/xvec.c"] tags: ["scheduler", "allocation", "compound", "code-review"] related: ["bug-1893"] +fix_commits: ["e822b888"] --- # bug-1892: xce_scheduler admission check reads per-resource uncommitted amounts by list position, not index @@ -72,15 +73,15 @@ shortfall. - Evidence: not kept (code reading only) ## Root cause -TODO: required for fixed/partial +`unsatisfy_()` (`src/scheduler/src/resource.c`) indexed the uncommitted vector positionally (`uncomitted[i]`) like `total`/`inuse`/`wanted`, but both callers, `sched_check_shared_satisfy_()` and `sched_check_host_satisfy_()`, pass the allocation context's dense vector keyed by resource index (`ctx->uncomitted.shared` / `.hosts[w]`, 1024 floats, filled with `xvec_idval()`). Entry `i` therefore read the uncommitted amount of resource index `i` instead of `wanted->idxs[i]`. It matters from the second primary of a COMPOUND/ALTER job on, the only place a context holds nonzero uncommitted amounts. ## Fix -TODO: required for fixed/partial +`unsatisfy_()` takes the uncommitted `xvec_t*` and reads it through a new `uncomit_at_(uncomitted, wanted->idxs[i])`, which returns 0 for a NULL vector, a negative index, or an index past the vector's end. The last case is needed because `sim_loop.c`'s reconcile checks pass a short all-zero vector sized to the request; reading it by resource index would otherwise run past its end. ## Verification -- Test: TODO: name + file; RED before the fix, GREEN after -- Suites: TODO: suite results and build profile -- Live: TODO: soak/deploy run, or n/a and why +- Test: `test_host_satisfy_counts_uncommitted_of_the_wanted_resource` RED ("Expected 0 Was 1": over-admit), `test_host_satisfy_ignores_uncommitted_of_another_resource` RED ("Expected 1 Was 0": wrong pend), `test_shared_satisfy_counts_uncommitted_of_the_wanted_resource` RED ("Expected 0 Was 1"), all GREEN after; `test_host_satisfy_short_uncommitted_vector_counts_as_zero` (guards the bounds check, passes before and after), all in testsuite/test_resource_accounting.c. +- Suites: scheduler ASAN suite 97/97 (build.alloc), 2026-10-01. +- Live: n/a for HA (no HA path touched). Sanity: the bug-1897 replay (`--sim`) still completes, exit 0, no ASan report. ## References - Related: none