Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hanging consoles: Close other client sockets in spring application forks #647

Merged
merged 1 commit into from Nov 23, 2021

Conversation

charkost
Copy link
Contributor

@charkost charkost commented Jun 14, 2021

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:

status = application.read.to_i
log "got exit status #{status}"
exit status

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.

@charkost charkost changed the title Close other client sockets in application forks Close other client sockets in spring application forks Jun 14, 2021
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.

The problem can be reproduced by opening 2 rails consoles on spring
& attempting to exit the first console while the second is still active.
@charkost charkost changed the title Close other client sockets in spring application forks Fix hanging consoles: Close other client sockets in spring application forks Jun 25, 2021
@rafaelfranca rafaelfranca merged commit 6bba044 into rails:master Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants