fix(scheduler): allocate every primary of a COMPOUND, not only the last (bug-1863)
Each primary's allocator (seqjob/parjob my_alloc) sets ctx->alloc to a
fresh job allocation covering only its own hosts, so a multi-primary
COMPOUND ("1*{A} + 2*{B}") dispatched only the last primary's hosts --
leaking the earlier allocations while every primary's hosts had been
debited in ctx.uncomitted.
sched_make_compound_alloc_ now folds each primary's allocation into one
job allocation via the new libxce merge_job_alloc(): a host placed by
several primaries becomes one entry with per-resource values added
(matched on resname, instid and reserve, so distinct instances are never
summed); new hosts and shared allocations are appended/merged the same
way. Partial-failure rollback remains bug-1766.
Tests: "1*{..} + 2*{..}" on 2x2 slots now allocates 3 slots across two
distinct hosts; "1*{..} + 1*{..}" yields one host entry with 2 slots
(both kept only the last primary before). Scheduler suite 87/87, lib 1/1.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a6a0502d62
commit
aea3473823
4 changed files with 176 additions and 5 deletions
|
|
@ -280,9 +280,10 @@ static int sched_make_compound_alloc_(xce_sched_core_t* core,
|
|||
xce_sched_obj_t* obj,
|
||||
xce_compound_resreq_t* resreq)
|
||||
{
|
||||
int i;
|
||||
xce_sched_ctx_t ctx;
|
||||
int rc = 0;
|
||||
int i;
|
||||
xce_sched_ctx_t ctx;
|
||||
xce_job_alloc_t* merged = NULL;
|
||||
int rc = 0;
|
||||
|
||||
sched_ctx_init(&ctx, core, obj);
|
||||
|
||||
|
|
@ -295,10 +296,27 @@ static int sched_make_compound_alloc_(xce_sched_core_t* core,
|
|||
if (rc <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* bug-1863: each primary's allocator sets a fresh ctx.alloc for its
|
||||
* own hosts only -- fold it into the whole compound's allocation
|
||||
* (every primary's hosts are already debited in ctx.uncomitted) */
|
||||
if (ctx.alloc != NULL) {
|
||||
if (merged == NULL) {
|
||||
MOVE_PTR(merged, ctx.alloc);
|
||||
} else {
|
||||
int mrc = merge_job_alloc(merged, ctx.alloc);
|
||||
|
||||
free_JobAlloc_ptr(&(ctx.alloc));
|
||||
if (mrc < 0) {
|
||||
rc = mrc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.alloc != NULL) {
|
||||
MOVE_PTR(obj->alloc, ctx.alloc);
|
||||
if (merged != NULL) {
|
||||
MOVE_PTR(obj->alloc, merged);
|
||||
}
|
||||
|
||||
if (ctx.reason != NULL) {
|
||||
|
|
|
|||
|
|
@ -797,6 +797,56 @@ static void test_alter_falls_back_to_alternative_that_fits(void)
|
|||
"the job must be placed by the second alternative (1 slot)");
|
||||
}
|
||||
|
||||
/*
|
||||
* bug-1863: each primary of a COMPOUND replaced ctx->alloc, so the
|
||||
* dispatched allocation kept only the LAST primary's hosts while every
|
||||
* primary's hosts had been debited. The whole compound must be allocated.
|
||||
*/
|
||||
static void test_compound_allocation_includes_every_primary(void)
|
||||
{
|
||||
xce_scheduler_t* sched = start_sched();
|
||||
xce_decision_t* decision;
|
||||
int i, j;
|
||||
|
||||
e2e_push_queue_and_workers(sched, "cmp2_queue");
|
||||
decision = e2e_dispatch_resreq(sched, JOB_ID + 5, "cmp2_queue",
|
||||
"1*{rusage[mem=1]} + 2*{rusage[mem=1]}");
|
||||
TEST_ASSERT_NOT_NULL(decision);
|
||||
TEST_ASSERT_EQUAL_INT(XCE_DECISION_DISPATCH, decision->op);
|
||||
TEST_ASSERT_EQUAL_FLOAT_MESSAGE(3.0f,
|
||||
(float)e2e_alloc_total_slots(decision->u.alloc),
|
||||
"1 + 2 tasks: the allocation must cover both primaries");
|
||||
|
||||
/* one entry per host */
|
||||
for (i = 0; i < decision->u.alloc->nhosts; i++) {
|
||||
for (j = i + 1; j < decision->u.alloc->nhosts; j++) {
|
||||
TEST_ASSERT_TRUE_MESSAGE(
|
||||
strcmp(decision->u.alloc->allocs[i]->host,
|
||||
decision->u.alloc->allocs[j]->host) != 0,
|
||||
"a host must appear once in a job allocation");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* bug-1863: two primaries landing on the same host merge into that host's
|
||||
* single entry (slots summed), not two entries or only the last one. */
|
||||
static void test_compound_primaries_on_same_host_merge(void)
|
||||
{
|
||||
xce_scheduler_t* sched = start_sched();
|
||||
xce_decision_t* decision;
|
||||
|
||||
e2e_push_queue_and_workers(sched, "cmp3_queue");
|
||||
decision = e2e_dispatch_resreq(sched, JOB_ID + 6, "cmp3_queue",
|
||||
"1*{rusage[mem=1]} + 1*{rusage[mem=1]}");
|
||||
TEST_ASSERT_NOT_NULL(decision);
|
||||
TEST_ASSERT_EQUAL_INT(XCE_DECISION_DISPATCH, decision->op);
|
||||
TEST_ASSERT_EQUAL_FLOAT(2.0f,
|
||||
(float)e2e_alloc_total_slots(decision->u.alloc));
|
||||
TEST_ASSERT_EQUAL_INT_MESSAGE(1, decision->u.alloc->nhosts,
|
||||
"both 1-task primaries fit the first 2-slot host -- one merged "
|
||||
"entry");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
|
|
@ -806,5 +856,7 @@ int main(void)
|
|||
RUN_TEST(test_alter_resreq_job_dispatches_via_real_allocator);
|
||||
RUN_TEST(test_compound_primary_needing_more_slots_than_exist_pends);
|
||||
RUN_TEST(test_alter_falls_back_to_alternative_that_fits);
|
||||
RUN_TEST(test_compound_allocation_includes_every_primary);
|
||||
RUN_TEST(test_compound_primaries_on_same_host_merge);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue