chore(buglog): bug-1893 fixed (d9ef9830, 239bcf95, 65679285)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-09-30 10:20:56 +00:00
parent 1f932bf22d
commit 3d3f37e0fd
Signed by untrusted user: rshen
GPG key ID: 80533536B0EB651C
2 changed files with 17 additions and 12 deletions

View file

@ -16550,9 +16550,9 @@
},
{
"id": "bug-1893",
"status": "open",
"status": "fixed",
"status_updated": "2026-09-30",
"status_note": "newly logged",
"status_note": "",
"component": "scheduler",
"severity": "wrong-result",
"timestamp": "2026-09-30T03:58:52Z",
@ -16560,8 +16560,8 @@
"occurrences": 1,
"error_message": "xce_scheduler allocators never record shared-resource pend reasons (vget rc check inverted)\n\n**Observed:** found by code reading, so there is no failing run yet. When the shared-resource check\nfails, both allocators add the pend reasons with\n```c\nfor (i = 0; i < ctx->alloc_req.shared.count; i++) {\n rc = vget(core->resmgr, ((int*)ctx->unmeet.idxs.data)[i], (void**)&r);\n if (rc <= 0) continue;\n add_job_preason(reason->reasons, PREASON_NO_RESOURCE, NULL, r->name);\n}\n```\n(`seqjob_allocator.c` `my_alloc`, `parjob_allocator.c` `my_alloc`). The loop\nbound is the number of *requested* shared resources, but `ctx->unmeet` holds\nonly the *unmet* ones, packed at `[0, unmeet.count)` by `unsatisfy_()`\n(`resource.c:152-165`). Its arrays were `calloc`ed with capacity\n`shared.count` (`resource.c:280`), so entries `[unmeet.count, shared.count)`\nare 0.\n\n**Expected:** iterate `i < ctx->unmeet.count` (as the host path does,\n`resource.c:566`), giving one `NO_RESOURCE` reason per unmet shared resource.\n\n**Impact:** wrong pend reason, noise level. When a job requests N shared\nresources and only M < N are unmet, the loop adds N - M extra\n`PREASON_NO_RESOURCE` reasons naming whatever resource has index 0 (if one\nexists), which that job may never have requested. Main reason and allocation\ndecision are unaffected. No out-of-bounds memory access (the tail is inside the\nallocation).\n\n**Found by:** review of the `scheduler-allocator-runner` requirements\n(2026-09-29); the loop moves into the framework runner in that spec.\n\nUPDATE (2026-09-30): Found in scheduler-allocator-runner task 2.1 (characterization test test_seqjob_pending_on_short_shared_no_reason_today): the observable effect is not an extra resource-0 reason. vget() (xzarray_get_vec, src/lib/zarray.c) returns 0 on success, and the loop skips on rc <= 0, so it skips every successful lookup and NO shared NO_RESOURCE reason is ever recorded; the over-read tail entries (idx 0) are skipped the same way. Real impact: a job pending on a short shared resource carries no resource reason naming it (main_reason stays 0). The host path (resource.c) correctly skips only rc < 0.",
"file": "src/scheduler/src/plugins/seqjob_allocator.c, src/scheduler/src/plugins/parjob_allocator.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": "Both allocators' `my_alloc()` shared-reason loop skipped on `vget() <= 0`, but `vget()` (`xzarray_get_vec`, src/lib/zarray.c) returns 0 on success, so every successful lookup was skipped and no shared `PREASON_NO_RESOURCE` reason was ever added. The loop also ran to `ctx->alloc_req.shared.count` instead of `ctx->unmeet.count` (the tail entries were zero-filled and skipped the same way).",
"fix": "Allocation moved into the framework runner (spec scheduler-allocator-runner). `sched_alloc_prepare_shared_()` in src/scheduler/src/alloc_runner.c loops over `ctx->unmeet.count` and skips only on `vget() < 0`, adding one host-less NO_RESOURCE reason per unmet shared resource. parjob (task 4.1) and seqjob (task 4.2) now allocate through it; both private loops are deleted.\n\nVerification:\n- Test: `test_shared_short_one_reason_per_unmet_entry` (testsuite/test_alloc_runner.c) RED under an `rc <= 0` skip (\"Expected 1 Was 0\"), GREEN after; characterization `test_parjob_pending_on_short_shared_names_short_one` and `test_seqjob_pending_on_short_shared_names_it` RED against the old plugins (\"Expected 1 Was 0\"), GREEN after the switch.\n- Suites: scheduler ASAN suite 96/96 (`bash src/tools/xce-build.sh scheduler asan build.alloc --jobs 12`), 2026-09-30.\n- Live: n/a (pend-reason content only; main_reason, decisions, unsatisfiable cache and sim parity unaffected).",
"tags": [
"scheduler",
"allocation",
@ -16571,7 +16571,11 @@
"related_bugs": [
"bug-1892"
],
"fix_commits": [],
"fix_commits": [
"d9ef9830",
"239bcf95",
"65679285"
],
"record": ".wolf/bugs/bug-1893.md"
},
{

View file

@ -1,8 +1,8 @@
---
id: "bug-1893"
status: "open"
status: "fixed"
status_updated: "2026-09-30"
status_note: "newly logged"
status_note: ""
component: "scheduler"
severity: "wrong-result"
timestamp: "2026-09-30T03:58:52Z"
@ -11,6 +11,7 @@ occurrences: 1
files: ["src/scheduler/src/plugins/seqjob_allocator.c", "src/scheduler/src/plugins/parjob_allocator.c"]
tags: ["scheduler", "allocation", "preason", "code-review"]
related: ["bug-1892"]
fix_commits: ["d9ef9830", "239bcf95", "65679285"]
---
# bug-1893: xce_scheduler allocators never record shared-resource pend reasons (vget rc check inverted)
@ -68,15 +69,15 @@ UPDATE (2026-09-30): Found in scheduler-allocator-runner task 2.1 (characterizat
- Evidence: not kept (code reading only)
## Root cause
TODO: required for fixed/partial
Both allocators' `my_alloc()` shared-reason loop skipped on `vget() <= 0`, but `vget()` (`xzarray_get_vec`, src/lib/zarray.c) returns 0 on success, so every successful lookup was skipped and no shared `PREASON_NO_RESOURCE` reason was ever added. The loop also ran to `ctx->alloc_req.shared.count` instead of `ctx->unmeet.count` (the tail entries were zero-filled and skipped the same way).
## Fix
TODO: required for fixed/partial
Allocation moved into the framework runner (spec scheduler-allocator-runner). `sched_alloc_prepare_shared_()` in src/scheduler/src/alloc_runner.c loops over `ctx->unmeet.count` and skips only on `vget() < 0`, adding one host-less NO_RESOURCE reason per unmet shared resource. parjob (task 4.1) and seqjob (task 4.2) now allocate through it; both private loops are deleted.
## 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_shared_short_one_reason_per_unmet_entry` (testsuite/test_alloc_runner.c) RED under an `rc <= 0` skip ("Expected 1 Was 0"), GREEN after; characterization `test_parjob_pending_on_short_shared_names_short_one` and `test_seqjob_pending_on_short_shared_names_it` RED against the old plugins ("Expected 1 Was 0"), GREEN after the switch.
- Suites: scheduler ASAN suite 96/96 (`bash src/tools/xce-build.sh scheduler asan build.alloc --jobs 12`), 2026-09-30.
- Live: n/a (pend-reason content only; main_reason, decisions, unsatisfiable cache and sim parity unaffected).
## References
- Related: none