Fix hanging consoles: Close other client sockets in spring application forks #647
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.
All client unix sockets are initiated at the spring application process before forking to serve each client.
A reference to the client socket remains active by the thread in the wait method waiting for the client's fork to exit.
This is problematic in cases with more than one parallel clients because the client socket for the first client is also present
in the fork for the second client due to fd inheritance from the spring application parent process.
With the first client's socket being present in the second client's fork, the first client cannot exit gracefully because
a reference to its socket remains open in the fork for the second client leading to rails console hanging
for the first client until the second client gets terminated:
spring/lib/spring/client/run.rb
Lines 167 to 171 in 577cf01
For read to return & release the client, all references to the socket should be closed.
The problem can be reproduced by opening 2 rails consoles on spring & attempting to exit the first console while
the second is still active.