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
vfs: losing data when doing writeback #4293
Comments
I am trying to make sure I'm following. You copy a file to the mount. The error you had posted looks like a file was changed during upload. |
You use chrome to download a file with a target destination somewhere in the mount. |
How does it fail though? When you a copy a file to the mount and the upload fails, it normally returns an IO write error on the mount. I'd probably update the title as that's not silent file corruption either. It's a missing file on a failed upload if I'm understanding you. |
The only way I understand that it fails is by seeing the log output of the mount process (https://termbin.com/g2o30). Chrome does not give out any errors and the file is perfectly readable and accessible in the mount directory, until it is remounted and disappears as it was never uploaded in the first place. What I tried to explain may not be "silent corruption". However it is still quite dangerous as the user does something very normal (download a file from the internet), the mount behaves as if the operation as successful (lists the file in the directory, allows the user to successfully read it), and eventually it turns out that the operation was unsuccessful. I don't know if/how Chrome handles IO errors when downloading files. However I suspect that there were no IO write errors given as the file wouldn't be placed in the mount in the first place. |
Without seeing a debug log, it's really a guessing game. When you fail an upload, it gives an IO error on a mount as that's an easy test on a mount in Linux terminal. Your issue is a duplicate of this one: I'd surmise Chrome is hiding the IO error and losing files is always a bad thing. I'd be more curious on fixing when you have some many upload failures? That in itself seems strange. |
The observed behaviour really seems identical to #2382. However in the latter's description it is stated that this happens when "the VFS cache will begin deleting any non uploaded files when they reach their retries amount." What I observe here is that the operation is cancelled even before reaching the stated retries amount and the delay between retries. It may still be the same issue triggered by a different stimulus however. I double checked the log I sent to @ncw and I think that it's safe to post here too, so here it is: https://termbin.com/93kb I think think that rclone gets confused when chrome first creates an empty file, this empty file is uploaded to the backend, rclone comes back to check if the sizes are the same and by that time chrome has already filled up that local file with content, hence the uploaded file is rejected. |
Here is an edited annotated log of what happened
The error in question is this one
That is onedrive complaining that you are about to rename a file on top of an existing file. Renaming a file on top of another file isn't part of the integration tests which means that rclone backends are differ in their implementations. The local backend will overwrite an existing file whereas the onedrive backend throws an error. If the onedrive backend had allowed the rename in this case then it would have worked. This would also have been fixed by the delayed writeback I have implemented in the vfs branch. |
I just ran into this issue but using Google Drive. @ncw will the fix you put together also fix it for other backends like Google Drive? |
I hope this should be fixed in the latest beta if someone wants to try it. |
@ncw not sure if you want me to keep updating the forum post and this issue, but anyway I did try the latest beta and it didn't seem to improve things. Still unable to save files from the browser straight onto the Google Drive mounted path. It feels like a regression actually as |
Ok let's move the discussion here:
I can replicate that.
When I try it with --vfs-cache-mode writes it works perfectly for me - can you post a log of that failing for you? I had a go at fixing the problem without --vfs-cache-mode - can you have a go with this? v1.52.2-233-g10dea1ca-fix-vfs-write-beta on branch fix-vfs-write (uploaded in 15-30 mins) |
I've just realised that the original poster on the forum was using Google drive - this should be fixed with and without --vfs-cache-mode writes With testing with onedrive, I see it working too, but without --vfs-cache-mode writes I see these errors which chrome somehow fixes up.
|
…4293 Due to Chrome's rather complicated use of file handles when saving files from the download windows, rclone was attempting to truncate a closed file. The file appeared closed due to the handling of 0 length files. This patch removes the check for the file being closed in the WriteFileHandle.Truncate call. This is safe because the only action this method takes is to emit an error message if the file is the wrong size. See: https://forum.rclone.org/t/google-drive-cannot-save-files-directly-from-browser-to-gdrive-mounted-path/17992/
…needs tests Some backends (eg onedrive) will throw an error if we rename over an existing file and some (drive) will create a duplicate. This patch checks to see if the destination exists and removes it or returns an error as appropriate. Fixes #4293
I a go at fixing up the rename issue - can you try this? It contains the previous fix too v1.52.2-234-g8f36afac-fix-4293-vfs-write-beta on branch fix-4293-vfs-write (uploaded in 15-30 mins) |
That's great @ncw! Thank you! 🙇 Seems to work fine without any errors (not using |
Thanks for testing :-)
Great! Can you try with
I noticed the code previously was making duplicates so it is possible you had a duplicate. Can you try this again with a fresh file? |
Yep! that works too. Should I be using with or without?
Just tried and after removing the file locally, it still doesn't seem to disappear when I go through drive.google.com. |
Thanks for testing. Without will save using up local disk space so if it works like that then I'd use it without.
OK let's work on this now! Can you make a sequence of steps for me showing all the commands you use that I can reproduce this? |
Due to Chrome's rather complicated use of file handles when saving files from the download windows, rclone was attempting to truncate a closed file. The file appeared closed due to the handling of 0 length files. This patch removes the check for the file being closed in the WriteFileHandle.Truncate call. This is safe because the only action this method takes is to emit an error message if the file is the wrong size. See: https://forum.rclone.org/t/google-drive-cannot-save-files-directly-from-browser-to-gdrive-mounted-path/17992/
What is the problem you are having with rclone?
When running the below command and downloading an arbitrary file from chromium (in my case - a pdf from google drive) directly into a mounted rclone remote, the file appears successfully downloaded in the directory, and is accessible by file managers and reader programs. However after remounting the rclone mount, the file disappears, as rclone actually silently failed uploading it. This is very dangerous for users who do not constantly monitor rclone mount's terminal output, where we can see the following transmission errors: https://termbin.com/g2o30
Even after enabling the options
--retries 99 --retries-sleep 10s
, which should force rclone to retry the same process after a delay, the upload still fails once it is initiated and is not retried. This can lead to involuntary data loss as was for my case.I haven't tried, but I suspect that using
cache
as a wrapper backend could work as a temporary workaround. I presume that rclone gets confused due to chrome's way of downloading files and then renaming them to the target name.What is your rclone version (output from
rclone version
)rclone v1.51.0
Which cloud storage system are you using? (eg Google Drive)
Onedrive for Business, without extra chained remotes sych as crypt, chunker, or cache.
The command you were trying to run (eg
rclone copy /tmp remote:tmp
)rclone -vv --retries 99 --retries-sleep 10s --vfs-cache-mode full mount remote: ~/somedir
A log from the command with the
-vv
flag (eg output fromrclone -vv copy /tmp remote:tmp
)I've emailed it to @ncw as it may contain sensitive information.
The text was updated successfully, but these errors were encountered: