Repository navigation
Fix DagProcessorJob crash on orphan processor kill (#69523) - #72888
Merged
Merged
Conversation
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)
vatsrahul1001
requested review from
amoghrajesh,
ashb,
ephraimbuddy,
jedcunningham and
kaxil
as code owners
September 10, 2026 14:16
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #69523 to
v3-3-testfor the 3.3.2 release.Fixes the DagProcessorJob dying with
ValueError: write to closed filewhen an orphaned processor is force-killed:supervisor.pygainscleanup_sockets_after_kill()(drains + closes the log-bearing sockets after a kill) and_log_to_target()(swallows the "closed file" error). The processor'sclose()calls the new cleanup.Backport adaptation (this fix sits on un-backported DAG-processor refactors not on
v3-3-test):supervisor.pychanges applied clean.DagFileProcessorProcessonv3-3-testdid not inheritLoggingMixin(main does) — added it, which provides theself.logused byclose()and the instance__dict__the tests need. Also added theclose()override.manager.pyonv3-3-testcalledprocessor.logger_filehandle.close()directly at 3 sites; main callsprocessor.close()(which now also drains sockets). Rewired all 3 toprocessor.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?
Generated-by: Claude Code (Opus 4.8) following the guidelines