-
Notifications
You must be signed in to change notification settings - Fork 488
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 graceful terminate in filestore. #1120
Conversation
5dc1d27
to
2dbe5f7
Compare
Thank you for the PR. I am fine with reversing the order but ignoring all errors appears dangerous to me. A better approach would be to ignore errors when the file was already deleted (using |
Thanks for the review - updated to account for other errors. |
13883dc
to
302d7e9
Compare
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 the update! Just a few nits.
TY - Fixed the comments. |
I wonder if this change will actually allow the upload to be cleaned up if only one of the two files remain. Yes, the Terminate method would do that, but a DELETE request would fail because the filestore needs both files present in order to load the upload (and then terminate it). At least that's what I remember right now. Did you test the termination of an upload where one file has been deleted? |
Ahh, you are right, the handler would not allow it to pass and returns err not found at |
I am not sure if adjusting the handler logic is the correct way here. If the upload state on disk got corrupted (e.g. one of the two files is missing), the client will not be able to resume the upload and start a new one. Trying to consider and recover from every possible type of corruption in tusd would be challenging if not impossible. The better way to deal with corrupted states is to start a new upload and let the previous, corrupt upload be cleaned up by a cron job (e.g. a job that removes all files which are untouched for the last 24hrs). This approach would be more thorough as it can also clean up uploads that tusd considers corrupt. Does that make sense? Nevertheless, I would still merge this PR. Ignoring |
Yep ! The handler can only do so much. The cronjob approach looks good (the job can look at info file and match it with the os.stat and remove them after a threshold).
Sure. NP. |
Thank you for working on this! |
In the current logic, we first delete the bin file and then the info file. We should instead do the reverse and ignore any errors when deleting the bin file. This ensures that any disgraceful shutdown would properly recover.
Note: This is only fixed in the filestore for now - might need to fix for other stores as well.