myxce/.wolf
Rongsong Shen 38437e570e
fix(scheduler): don't hand an orphaned duplicate job to the picker
Found while chasing bug-1714's crash (root cause still open -- see that
entry): two related, independently-confirmed defects, not proven to be
bug-1714's own cause but real bugs on their own merits.

xce_core_push_events()'s JOBS_PUSH case never checked sched_add_job()'s
return value -- if key_add() failed (duplicate jobid), the freshly-built
xce_sched_job_t was handed to picker_iface->on_job_push() anyway, even
though it was never registered in core->jobs. An orphaned job the
picker knows about but sched_get_job() can never find again. Now checks
the return, frees the orphan (at core_build_job()'s own established
cleanup granularity -- xce_sched_job_t has no complete destructor
anywhere in this codebase, kill_sched_job() only frees ->rusages, so
this intentionally doesn't invent a more thorough one), and skips the
picker call.

This makes it safe to fix (not the other way around): sched_on_job_array()'s
per-element dedup check (handler.c) has a TOCTOU race -- a job is only
added to core->jobs later, by the driver thread, so a redelivered array
push arriving on the request thread before the driver catches up isn't
caught. Documented as a best-effort optimization, not a correctness
boundary -- the actual authoritative uniqueness check is sched_add_job()'s
key_add(), which the JOBS_PUSH fix above now handles correctly.

TDD: new test reproduces the duplicate-jobid path (RED: on_job_push
fired twice, Expected 1 Was 2), GREEN after the fix. Full scheduler
regression: 54/55, only the known bug-1561-adjacent flake.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QxaSzHRB7pmYFp4cVnwkA
2026-08-30 03:01:14 +00:00
..
hooks chore(wolf): checkpoint buglog.json (1062 bugs) 2026-08-27 08:27:43 +00:00
.gitignore chore(wolf): checkpoint buglog.json (1062 bugs) 2026-08-27 08:27:43 +00:00
_scan-state.json docs: save scheduler-snapshot-job-allocation and xce-test-cli-ux spec docs, sync OpenWolf state 2026-08-28 06:30:37 +00:00
anatomy-index.json docs: sync OpenWolf state 2026-08-29 12:13:15 +00:00
anatomy.md docs: sync OpenWolf state 2026-08-29 12:13:15 +00:00
buglog.json fix(scheduler): don't hand an orphaned duplicate job to the picker 2026-08-30 03:01:14 +00:00
cerebrum.md chore(wolf): checkpoint buglog.json (1062 bugs) 2026-08-27 08:27:43 +00:00
config.json docs: save scheduler-snapshot-job-allocation and xce-test-cli-ux spec docs, sync OpenWolf state 2026-08-28 06:30:37 +00:00
cron-manifest.json chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
cron-state.json docs: save scheduler-snapshot-job-allocation and xce-test-cli-ux spec docs, sync OpenWolf state 2026-08-28 06:30:37 +00:00
memory.md docs: sync OpenWolf state 2026-08-29 12:13:15 +00:00
OPENWOLF.md chore(wolf): checkpoint buglog.json (1062 bugs) 2026-08-27 08:27:43 +00:00
reframe-frameworks.md chore: checkpoint all prior work for clean state 2026-06-04 13:04:16 +00:00
STATUS.md chore(wolf): checkpoint buglog.json (1062 bugs) 2026-08-27 08:27:43 +00:00