Fix socket leak on monitor wakeup NoMethodError
in Reactor#select_loop
#3696
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.
Description
Closes #3695
This fixes the linked issue by narrowing the scope of the
NoMethodError
rescue logic in the reactor's select loop. Previously, the rescue logic targeted the entire loop iteration including wakeup processing. Now it only protects the@selector.select
call itself, which was the original intention.When a
lowlevel_error_handler
returns an invalid response (like a string instead of an array), the reactor thread would die during wakeup processing but leave the selector open, causing file descriptor leaks. By moving the rescue block to only wrap@selector.select
, exceptions during wakeup processing no longer terminate the reactor thread, preventing file descriptor exhaustion under high load.The
NoMethodError
rescue logic was originally added in commit fd259b7 to handle rare selector exceptions. It seems like it shouldn't be required, and that there's some underlying issue that should be fixed. I'd be happy to look into this in a follow-up so we can remove it altogether, but this patch should do for now.I will come back to add a test for this when I get a chance. I thought I'd open it early for feedback.
Manual testing:
master
fix-reactor-wakeup-no-method-error-fd-leak
Your checklist for this pull request
[ci skip]
to the title of the PR.#issue
" to the PR description or my commit messages.