Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
4.3 KiB
id, title, kind, expected_rounds
| id | title | kind | expected_rounds |
|---|---|---|---|
| debuglog-sched | Find why a job scheduler loses jobs from a production log, fix it and write it up | debug | 20-50 |
debuglog-sched
Notes for the orchestrator (not sent to Codex).
- Seed:
sched/(a lease-based job scheduler: queue, store, leases, dedupe, retry, metrics, a discrete-event simulator, about 780 lines withrun_sim.py), 31 visible unit tests (green on the seed) andlogs/service.log(4730 lines, 417 KB, generated bygen_log.pyfrom the seed code;gen_log.pyis not part of the seed). Reading the log with grep/sed in slices is the realistic way;cat-ing it whole would be about 150k tokens, so context growth towards 100k tokens depends on how much of the log the agent pages through. - The defect:
sched/ids.pymasks the id sequence to 12 bits (ID_MASK), so ids repeat after 4096 jobs. A long-running export job that still holds its lease gets its id issued again to a new job;JobStore.putoverwrites the record, so the first ack / heartbeat / claim after that finds nothing (ack for unknown job,claim of unknown job ... dropped,job ... vanished: lease expired while running), and the client's retry is swallowed bydedupe.py(dedupe hit ... not enqueued). The log shows the sequence goingj-fff->j-000(line 927-928), heartbeats of the old job before the reuse, and four incidents (lines 986/1009, 1456/1655, 2870/3055, 3991/4058). - Red herrings in the log: transient
failed attemptretries,queue_depth counter driftedwarnings (a harmless hand-kept gauge), slow-job warnings, twodead after 3 attemptserrors, and one frozen worker whose lease expires (line 2857) which also yields anack for unknown job-like pattern (claim of unknown job j-194), but with alease expiredline before it and no id reuse. - Acceptance (
accept.py): (1) the pristine visible tests (hidden/tests, copied overtests/) pass on the agent's code; (2)tests/test_regression.pyexists and passes; (3) the same file FAILS against the originalsched/(hidden/orig/sched), so a test that cannot detect the bug is rejected; (4) two hidden stress simulations (140,000 jobs / 3 workers, 100,000 jobs / 5 workers, different seeds and traffic) run with the pristinesim.pyon top of the agent's service code and must lose and duplicate nothing (about 5 s each); (5)FINDINGS.mdnamesids.pyandnext_id/IdGenerator, talks about wrap/reuse/collision, and cites a number within 2 of an evidence line (hidden/evidence.json, written bygen_log.py). Any fix that stops ids from colliding passes (removing the mask, skipping ids in use, a wider counter, uuid-like ids that keep the pristine tests green). Because the pristinesim.pyis used, a fix must keep theSchedulerconstructor and method signatures. - The original code loses 18 jobs in stress a and 27 in stress b; the reference fix (
reference/overlay) loses none. Deterministic: seeded virtual-clock simulation, no wall clock, no network; Python 3.9 .. 3.14. - To regenerate the log (not needed):
python3 gen_log.pywritesseed/logs/service.logandhidden/evidence.json; the output is byte-identical on Python 3.9 and 3.12.
Prompt
Production lost some jobs. Customers are complaining that some of their jobs never completed, and on-call saw ack for unknown job warnings and vanished errors in the scheduler log. The log of the incident is logs/service.log (about 4,700 lines, so use grep and sed to look at slices of it rather than printing the whole file). The scheduler code is in sched/; run_sim.py replays a synthetic workload through the same code on a virtual clock (python3 run_sim.py --help), and the unit tests run with python3 -m unittest discover -s tests.
Please:
- Find the root cause of the lost jobs. The log has enough information to localise it.
- Fix it in the code. Keep the existing tests green.
- Add a regression test in
tests/test_regression.pythat fails on the old code and passes with your fix. - Write
FINDINGS.mdin the repository root with the root cause (file and function), the evidence (line numbers inlogs/service.log) and the fix you made.
There is no network here and only the Python 3 standard library is available (no pytest). When you are done, reply with a short summary of the root cause and the fix.