fix(bug-1727): 'info worker'/'info resource' double-counted used capacity
repl_info_worker_one()/repl_info_resource_one() (repl_info.c) printed
value=avail+used for a CONSUMABLE resource, on the assumption that
avail_v holds a live "remaining capacity" figure that shrinks as jobs
run. That assumption was false: w->resvals[idx] (and
core->sharedInst[idx] for shared resources) is the resource's STATIC
TOTAL capacity, self-reported by the worker at join/heartbeat time and
never decremented as jobs consume it -- confirmed against the actual
admission-control formula this same field feeds (resource.c's
unsatisfy_(): `total[i] < inuse[i] + uncomitted[i] + wanted[i]` treats
it as a total, not a pre-reduced remaining figure). Printing avail+used
therefore double-counted `used` on top of a value that already
included it.
Live-reproduced against a real 3-node cluster + worker: a fully-packed
22-slot worker showed "value=44.00 used=22.00" instead of the correct
"value=22.00 used=22.00" (22 never-decremented total + 22 used = 44,
matching this bug's mechanism exactly). This was previously
investigated as bug-1727 ("recorded for future investigation only") --
confirmed its hypothesis (a) and closed it here rather than opening a
new entry.
Fixed by printing avail_v as-is (no addition) at both call sites.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QxaSzHRB7pmYFp4cVnwkA
This commit is contained in:
parent
0e78f86377
commit
fc55994813
2 changed files with 86 additions and 28 deletions
|
|
@ -759,9 +759,16 @@ static void test_info_worker_reports_resource_values(void)
|
|||
|
||||
/*
|
||||
* New requirement (2026-08-20): a per-worker resource additionally flagged
|
||||
* XCE_RESF_CONSUMABLE must report both value (available+inUse) and used
|
||||
* (inUse); a non-consumable numeric resource keeps a single value= line
|
||||
* (test_info_worker_reports_resource_values above covers that case).
|
||||
* XCE_RESF_CONSUMABLE must report both value (its raw total capacity) and
|
||||
* used (inUse); a non-consumable numeric resource keeps a single value=
|
||||
* line (test_info_worker_reports_resource_values above covers that case).
|
||||
*
|
||||
* bug-1727 (2026-08-30): corrected from the original "value=
|
||||
* avail+used" expectation -- w->resvals[idx] (avail_v) is ALREADY the
|
||||
* total capacity (never decremented as jobs consume it; see resource.c's
|
||||
* unsatisfy_() admission formula), so adding `used` on top double-counted
|
||||
* it. See repl_info_worker_one()'s updated doc comment (repl_info.c) for
|
||||
* the full live-reproduced evidence.
|
||||
*/
|
||||
static void test_info_worker_reports_consumable_value_and_used(void)
|
||||
{
|
||||
|
|
@ -824,9 +831,9 @@ static void test_info_worker_reports_consumable_value_and_used(void)
|
|||
captured = capture_dispatch(&sim, "info worker hostA");
|
||||
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(
|
||||
strstr(captured, "resource slots: value=7.00 used=2.00"),
|
||||
"a CONSUMABLE worker resource must report value=avail+used and "
|
||||
"used=inUse");
|
||||
strstr(captured, "resource slots: value=5.00 used=2.00"),
|
||||
"a CONSUMABLE worker resource must report value=<raw total, "
|
||||
"not avail+used> and used=inUse (bug-1727)");
|
||||
|
||||
free(captured);
|
||||
|
||||
|
|
@ -1109,10 +1116,14 @@ static void test_info_resource_reports_string_value(void)
|
|||
|
||||
/*
|
||||
* New requirement (2026-08-20): a GLOBAL/SHARED resource additionally
|
||||
* flagged XCE_RESF_CONSUMABLE must report both its value (capacity,
|
||||
* available+inUse) and how much is currently in use, read from
|
||||
* core->sharedInUse -- the cluster-wide mirror of repl_info_worker_one()'s
|
||||
* resInUse-derived value/used split.
|
||||
* flagged XCE_RESF_CONSUMABLE must report both its value (raw total
|
||||
* capacity) and how much is currently in use, read from core->sharedInUse
|
||||
* -- the cluster-wide mirror of repl_info_worker_one()'s resInUse-derived
|
||||
* value/used split.
|
||||
*
|
||||
* bug-1727 (2026-08-30): corrected from the original "value=
|
||||
* avail+used" expectation -- same double-count fix as the per-worker case
|
||||
* above.
|
||||
*/
|
||||
static void test_info_resource_reports_consumable_value_and_used(void)
|
||||
{
|
||||
|
|
@ -1163,9 +1174,10 @@ static void test_info_resource_reports_consumable_value_and_used(void)
|
|||
captured = capture_dispatch(&sim, "info resource licenses");
|
||||
|
||||
TEST_ASSERT_NOT_NULL_MESSAGE(
|
||||
strstr(captured, "value=11.00 used=3.00"),
|
||||
"a CONSUMABLE global resource must report value=avail+used and "
|
||||
"used=inUse, sourced from core->sharedInUse");
|
||||
strstr(captured, "value=8.00 used=3.00"),
|
||||
"a CONSUMABLE global resource must report value=<raw total, not "
|
||||
"avail+used> and used=inUse, sourced from core->sharedInUse "
|
||||
"(bug-1727)");
|
||||
|
||||
free(captured);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue