Fix rclone backend not properly handling subprocess exit#2797
Closed
greatroar wants to merge 2 commits intorestic:masterfrom
Closed
Fix rclone backend not properly handling subprocess exit#2797greatroar wants to merge 2 commits intorestic:masterfrom
greatroar wants to merge 2 commits intorestic:masterfrom
Conversation
6 tasks
This forces an error in the REST backend, which otherwise would hang indefinitely. Fixes restic#2381.
8 tasks
Member
The default behavior of Go is to trigger The root cause for restic not noticing the subprocess exit is that restic currently holds on to file descriptors for both the read and write side of the stdin and stdout pipes. That prevents the pipes from closing properly. Calling I've built a different version of this PR (including your test case) which properly fixes the pipe setup and hopefully also the rclone test failures: #2855 |
Contributor
Author
|
Closing in favor of #2855. |
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.
What is the purpose of this change? What does it change?
When rclone exits unexpectedly, restic can hang. The problem occurs in the REST backend, which does not detect that its connection over stdin/stdout has stopped working.
This patch is a (hacky) fix for that problem: it simply closes stdin and stdout when the process is gone. Why this doesn't produce a SIGPIPE is beyond me. The error message is ugly, but at least it arrives instantly.
I have some ideas about how to fix this properly, but they may require quite a bit of code (if they even turn out correct). I suggest merging this as a hotfix.
I was hoping to fix the flaky rclone test, but I don't think this patch does that.
Was the change discussed in an issue or in the forum before?
Fixes #2381.
Checklist
changelog/unreleased/that describes the changes for our users (template here)gofmton the code in all commits