-
-
Notifications
You must be signed in to change notification settings - Fork 350
Fix zombie ssh processes from accumulating #1333
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd feel better if we could remove the
kill()
then. Despite being aware that it would probably prevent to hang in thewait()
call, I'd only want to add it when it's proven to be necessary. Since Git doesn't seem to be doing that, I think neither should we.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed it in my most recent update. I also confirmed that with this change, my application (a long-running daemon that uses gitoxide to do tons of git clones over SSH) does not show any zombied ssh processes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I spoke too soon! Seems there's some tests where removing the
kill()
is causing a hang. Let me look into this...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for running this experiment!
In this case, Git might not even have all the answers as it would never encounter such a case, after all, it can't be used as a library.
Something that surprises me though is how
wait()
(withoutkill()
) can still leave zombies - if it doesn't block forever then it should shut down the child for good.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean... The issue with the test hang is that
wait()
is blocking forever. After adding thewait()
, we are guaranteed to never have zombies (at least for this child process scenario) - we're just exposed to a deadlock possibility if thessh
process didn't shutdown gracefully.I was able to fix the test hang with this change:
But... now that I look at it more, I feel like there's other scenarios where tke
kill()
is going to be needed. For example, while we're in the middle of reading the pack, the user can abort the operation viashould_interrupt
. If that happens, then there is no "graceful" way to indicate to the remote that we'd like to shutdown (AFAIK).Thoughts @Byron ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I didn't know that deadlocks are actually happening then, and it makes sense to see these until the remote hangs up. Oh, and it looks like CI is already deadlocking.
And it's true, once interrupted, everything winds down and it's unclear in which state
ssh
is in that moment, so a kill() call would be required. Git is different, as in doesn't have that problem, as they just abort on signal. There is some special handling for tempfiles, but that's about it.Thus, we really have to call kill here. Could you protect that
kill()
call with a comment that briefly explains why?Then I think this can be merged, and we are back to were we were, but with a comment and a better understanding :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thanks for the feedback!