fix(scheduler): re-queue job as PEND on dispatch failure (bug-1494 class)

The controller rejects a dispatch when the chosen worker is not in a
dispatchable state (UNAVAIL after a worker death, or still joining) and
replies with a jobDispatchFail notify. The scheduler had no handler for that
event, so a job it had just committed (state=RUN) was never returned to PEND
— it was never re-elected and stayed PEND cluster-wide even after the worker
recovered.

Handle NotifyData_data_jobDispatchFail: log the failure and call the new
sched_requeue_pend_job(), which frees the dispatch bookkeeping, resets the
job to PEND, and re-enqueues it in the fcfs pendJobs queue so the next
election session re-dispatches it. White-box test TUs that #include
handler.c get a sched_requeue_pend_job stub.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
lei.chen 2026-08-11 03:19:07 +00:00
parent 5657fca7f7
commit 6928f74702
6 changed files with 94 additions and 0 deletions

View file

@ -56,6 +56,18 @@ xce_sched_job_t* sched_get_job(xce_scheduler_t* sched, uint64_t jobid)
return job;
}
/* White-box stub for sched_requeue_pend_job (handler.c's jobDispatchFail
* case), backed by this TU's real kvmgr sched_get_job. */
int sched_requeue_pend_job(xce_scheduler_t* sched, uint64_t jobid)
{
xce_sched_job_t* job = sched_get_job(sched, jobid);
if (job == NULL) {
return -ENOENT;
}
job->state = JOB_STAT_PEND;
return 0;
}
void setUp(void) { return; }
void tearDown(void)
{