fix(rerun): shut down live worker on eval start to prevent blueprint … - #269
fix(rerun): shut down live worker on eval start to prevent blueprint …#269Adityakk9031 wants to merge 1 commit into
Conversation
jeqcho
left a comment
There was a problem hiding this comment.
Thanks for picking up #267 so quickly — this lands exactly the candidate fix the issue sketched, and it's in the right place: stopping a leftover worker before the blueprint reset (and before rr.init re-points the global recording) closes the reset interleave and bounds cross-eval step contamination. The is_alive() guard is a nice touch too, since it keeps the normal start path from paying the _probe_recording_flush timeout. I also verified the new test fails without the source change and passes with it, so it genuinely guards the fix.
A few small asks before merge, all in the test:
- The hand-rolled
FiringRRfake is missingScalars/Scalar, so the worker's emit actually raisesAttributeErrorinside the test and triggers the "RerunSink failed to emit a step" warning (you can see it in the pytest output), andFiringRR.eventsnever receives anything. Please use the file's existing_install_fake_rerun(monkeypatch)+_log_one(sink, t)helpers instead — they simulate a working SDK surface, avoid the stray warning, and will roughly halve the test. - Placement: the test currently sits between
test_real_rerun_accepts_the_blueprintandtest_real_rerun_process_exits_when_tcp_peer_never_reads, which are the real-SDK group at the end of the file. It fits better next totest_eval_end_shuts_down_worker_and_log_step_restarts_itwith the other lifecycle tests. - This module comments its non-obvious moves pretty thoroughly — a one-liner above the new guard (e.g. "a crash path can skip
on_eval_end; stop the previous eval's worker before resetting blueprint state so its writes can't land after the reset") would help future readers. - Optional, but worth a sentence in the PR description: the disowned-worker case (a worker wedged in
send_blueprintpastflush_timeout) can still set_blueprint_warnedafter the reset, so #267's cosmetic race 2 is narrowed rather than fully eliminated. Fine to still close the issue given how it was framed — just good to state the residual explicitly.
The core change is solid; happy to approve once the test is reworked.
b1cb278 to
1770d1c
Compare
1770d1c to
3886a3a
Compare
|
Thanks for the detailed review @jeqcho! I have addressed all the feedback and rebased the branch onto the latest
|
Closes #267.
Problem
When an eval ends without
on_eval_end(e.g. Ctrl-C or crash path) and the caller reuses theRerunSinkinstance, the still-running worker thread from the previous eval can interleave withbind_spacesandon_eval_startblueprint resets on the subsequent eval. This could cause torn blueprint payloads or suppressed blueprint warnings.Fix
In
on_eval_start, check if a worker thread is still alive and shut it down before resetting_blueprint_prefixand_blueprint_warned.Verification
ruff check .— Passed.ruff format --check .— Passed.pytest tests/test_rerun_sink.py— 66 passed, 4 skipped, 0 failures.