process_messages: don't let a failed error report skip worker teardown - #198
Open
vtjnash wants to merge 1 commit into
Open
process_messages: don't let a failed error report skip worker teardown#198vtjnash wants to merge 1 commit into
vtjnash wants to merge 1 commit into
Conversation
A worker should not outlive its master, but the `exit(1)` enforcing that sat behind error reporting which fails in many of the same circumstance the exit exists for. Since `start_worker` redirects a worker's stderr to its stdout, a pipe held only by the master, when the master dies the worker's `EOFError` handling writes to a reader-less pipe and raises `EPIPE` killing the unmonitored Task. The `@error` rethrows when `catch_exceptions(logger)` is false, and even when true the recovery report in `Base.CoreLogging.logging_error` writes to the same broken stream unguarded. So the throw escaped `message_handler_loop`'s `catch`, skipping both `exit(1)` and the stream closes, and the worker then idled in `start_worker`'s wait loop indefinitely, with its socket in `CLOSE-WAIT`. Arm the exit-on-completion of the task servicing the connection to master so it no longer depends on anything in the error path succeeding, and guard the remaining raw `stderr` writes that gate cleanup in `deliver_result`, `connect_to_peer`, and the unidentified-peer branch of `message_handler_loop`. Several existing patterns are split into separate functions so we can drive those from the test to be precise and minimal. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #198 +/- ##
==========================================
+ Coverage 79.10% 79.37% +0.26%
==========================================
Files 10 10
Lines 1977 2027 +50
==========================================
+ Hits 1564 1609 +45
- Misses 413 418 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
A worker should not outlive its master, but the
exit(1)enforcing that sat behind error reporting which fails in exactly the circumstance the exit exists for.start_workerredirects a worker's stderr to its stdout, a pipe held only by the master, so when the master dies the worker'sEOFErrorhandling writes to a reader-less pipe and raisesEPIPE.@errordoes not contain that: whencatch_exceptions(logger)is false it rethrows, and when true the recovery report inBase.CoreLogging.logging_errorwrites to the same broken stream unguarded. The throw escapedmessage_handler_loop'scatch, skipping bothexit(1)and the stream closes, and the worker then idled instart_worker's wait loop indefinitely, holding its socket inCLOSE-WAIT.Arm the exit on completion of the task servicing the connection to pid 1 so it no longer depends on anything in the error path succeeding, and guard the remaining raw
stderrwrites that gate cleanup indeliver_result,connect_to_peer, and the unidentified-peer branch ofmessage_handler_loop.