Skip to content

Fix DagProcessorJob crash on orphan processor kill (#69523) - #72888

Merged
vatsrahul1001 merged 1 commit into
v3-3-testfrom
backport-6d9cc2ed37-v3-3-test
Sep 10, 2026
Merged

vatsrahul1001 merged 1 commit into
v3-3-testfrom
backport-6d9cc2ed37-v3-3-test

Conversation

@vatsrahul1001

Copy link
Copy Markdown
Contributor

Backport of #69523 to v3-3-test for the 3.3.2 release.

Fixes the DagProcessorJob dying with ValueError: write to closed file when an orphaned processor is force-killed: supervisor.py gains cleanup_sockets_after_kill() (drains + closes the log-bearing sockets after a kill) and _log_to_target() (swallows the "closed file" error). The processor's close() calls the new cleanup.

Backport adaptation (this fix sits on un-backported DAG-processor refactors not on v3-3-test):

  • supervisor.py changes applied clean.
  • DagFileProcessorProcess on v3-3-test did not inherit LoggingMixin (main does) — added it, which provides the self.log used by close() and the instance __dict__ the tests need. Also added the close() override.
  • manager.py on v3-3-test called processor.logger_filehandle.close() directly at 3 sites; main calls processor.close() (which now also drains sockets). Rewired all 3 to processor.close(), matching main exactly (behavior-preserving plus the socket drain).

Verification: the 3 new orphan-kill/close tests pass; full test_manager.py + test_processor.py = 219 passed; ruff clean.

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 4.8)

Generated-by: Claude Code (Opus 4.8) following the guidelines

After a processor is SIGKILLed its sockets stay registered on the shared
selector, so the next select() callback writes to an already-closed log
handle and the job dies with "ValueError: write to closed file".

Add WatchedSubprocess.cleanup_sockets_after_kill() to drain the log-bearing
sockets, run their close callbacks and unregister them, and call it from
DagFileProcessorProcess.close(). Request sockets are closed without being
drained so no request frames get dispatched after the kill.

Also route supervisor log writes through _log_to_target() so a logger whose
handle is already closed is skipped instead of taking the process down.

closes: #64959

Co-authored-by: Rahul Vats <43964496+vatsrahul1001@users.noreply.github.com>
(cherry picked from commit 6d9cc2e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants