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

@ -260,7 +260,8 @@ func dispatchJobArray(handler NotificationHandler, elements []*models.JobInfo, b
nNew := 0
for _, job := range elements {
jobid := uint64(job.Unique_JobID)
if store.Jobs.Has(jobid) {
// A provisional record (bug-1894) is not a duplicate: replace it.
if existing, ok := store.Jobs.Get(jobid); ok && !existing.Provisional {
continue
}
handler.OnJobUpdated(job)