Commit Graph

4 Commits

Author SHA1 Message Date
Andrew Bagrin b7c59bda54 fix(cron): isolate per-execution working directories 2026-08-31 09:59:39 -07:00
Teknium 89b38ed734 test(cron): migrate one-shot-intent fixtures to the 'in 30m' form
Sibling tests outside the salvaged PR's files created one-shots via bare
'30m', which is now a recurring interval per the corrected contract.
Fixtures whose assertions depend on kind='once' (run-claim clearing,
terminal-record rearm, web-server completed-snapshot) now use 'in 30m';
sites indifferent to kind keep the bare form.
2026-08-29 19:19:40 -07:00
kshitij baa1cfb89d perf(cron): skip run_claim clear for recurring jobs on dispatch failure
/simplify-code finding: only one-shots carry a run_claim, yet the three
dispatch-failure paths called clear_run_claim unconditionally — each call
acquires _jobs_lock (blocking cross-process flock) and does a full
load_jobs read just to return False for any non-'once' job. The trigger
is exactly a failure storm (interpreter shutdown, EMFILE with N due
jobs): N serialized flock+file reads at the moment the process can least
afford I/O, all guaranteed no-ops for the majority job kind.

Gate at the call site on schedule.kind == 'once'; new mutation-checked
test proves recurring dispatch failures skip the claim I/O entirely.

9/9 tests green; ruff clean.
2026-08-17 17:31:26 +05:30
kshitij 70fc5a5ee2 fix: guard claim cleanup best-effort + add #86522 regression tests
Follow-ups on the #87591 salvage:

- cron/scheduler.py: wrap the three clear_run_claim call sites in a
  best-effort helper — clear_run_claim does load_jobs/save_jobs file I/O,
  and on the interpreter-shutdown path (or with a corrupt store) it could
  itself raise, defeating the skip-cleanly purpose of these early exits.
  A claim that can't be cleared simply expires at the TTL, as before.
- tests/cron/test_oneshot_dispatch_failure_run_claim.py (new): 8 tests —
  clear_run_claim unit contract (one-shot cleared / already-clear noop /
  recurring never touched / unknown id), all three dispatch-failure paths
  through a real tick() clear the claim, and a raising clear_run_claim
  does not crash the tick. Mutation-verified: reverting the fix makes the
  suite fail.
2026-08-17 17:31:26 +05:30