fix(apiserver): an accepted job is in the job store at once (bug-1894)

The apiserver's job store learned of a new job only from the
controller's asynchronous OnJobCreated / array push, so a 'jobs kill'
(or query) straight after 'jobs submit' could answer 'job not found'
for the job just accepted (2 of 4 immediate kills).

services.SubmitJob now records the accepted job right after the
controller's reply (which comes only after the job is committed and
applied): one record per element, base+i for arrays, stored with the new
DataStore.PutIfAbsent and marked JobInfo.Provisional (json:"-", not a
column). An OnJobCreated that already arrived is never overwritten; the
push that arrives later replaces the provisional record -- including in
dispatchJobArray, whose duplicate check no longer treats a provisional
element as already known.

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

View file

@ -6,6 +6,13 @@ import (
)
// SubmitJob sends a job to the backend. arraySize=1 for normal, >1 for array.
// On success the accepted job is recorded in the job store right away
// (bug-1894), so it can be queried and controlled before the controller's
// asynchronous OnJobCreated push arrives.
func SubmitJob(job *models.JobInfo, arraySize int) error {
return backend.SubmitJob(job, arraySize)
if err := backend.SubmitJob(job, arraySize); err != nil {
return err
}
backend.RecordAcceptedJob(job, arraySize)
return nil
}