Skip to content

vfs: losing data when doing writeback #4293

Closed as not planned
Closed as not planned

Description

@Zvezdin

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

  • os/arch: linux/amd64
  • go version: go1.14.2

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 from rclone -vv copy /tmp remote:tmp)

I've emailed it to @ncw as it may contain sensitive information.

Activity

  1. animosity022 commented on May 31, 2020

    @animosity022
    Contributor

    I am trying to make sure I'm following.

    You copy a file to the mount.
    It fails uploading because of something.
    You remount and the file that was there is gone?

    The error you had posted looks like a file was changed during upload.

  2. Zvezdin commented on May 31, 2020

    @Zvezdin
    Author

    You use chrome to download a file with a target destination somewhere in the mount.
    It fails. You remount and it's gone.

  3. animosity022 commented on May 31, 2020

    @animosity022
    Contributor

    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.

  4. Zvezdin commented on May 31, 2020

    @Zvezdin
    Author

    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.

  5. animosity022 commented on May 31, 2020

    @animosity022
    Contributor

    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:

    #2382

    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.

  6. Zvezdin commented on May 31, 2020

    @Zvezdin
    Author

    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.
    What is weird here is why rclone does not retry the same upload operation as given by the flags --retries 99 --retries-sleep 10s

  7. ncw commented on Jun 2, 2020

    @ncw
    Member

    Here is an edited annotated log of what happened

    # Download finishes, Firefox closes the file, rclone finishes the upload
    2020/05/31 14:01:52 DEBUG : Unconfirmed 499231.crdownload: transferred to remote
    # Firefox opens the destination file and clears it to empty
    2020/05/31 14:01:52 DEBUG : somefile.pdf: Open: flags=O_WRONLY|O_CREATE|O_TRUNC
    2020/05/31 14:01:52 DEBUG : somefile.pdf(0xc000a08380): Opening cached copy with flags=O_WRONLY|O_CREATE|O_TRUNC
    2020/05/31 14:01:52 DEBUG : somefile.pdf(0xc000a08380): close:
    # Firefox renames the .crdownload to somefile.pdf
    2020/05/31 14:01:52 DEBUG : /: Rename: oldName="Unconfirmed 499231.crdownload", newName="somefile.pdf", newDir=/
    # rclone decides that the (now empty) somefile.pdf needs to be transferred
    2020/05/31 14:01:52 DEBUG : somefile.pdf: Need to transfer - File not found at Destination
    # rclone renames the file in the cache
    2020/05/31 14:01:52 INFO  : Unconfirmed 499231.crdownload: Renamed in cache
    # rclone starts the somefile.pdf upload
    2020/05/31 14:01:52 DEBUG : somefile.pdf: Starting singlepart upload
    # rclone attempts to rename in onedrive but there is a file there already - the 0 sized somefile.pdf
    2020/05/31 14:01:53 ERROR : Unconfirmed 499231.crdownload: Couldn't move: nameAlreadyExists: Name already exists
    2020/05/31 14:01:53 ERROR : somefile.pdf: File.Rename error: nameAlreadyExists: Name already exists
    2020/05/31 14:01:53 ERROR : Unconfirmed 499231.crdownload: Dir.Rename error: nameAlreadyExists: Name already exists
    2020/05/31 14:01:53 DEBUG : /: >Rename: err=nameAlreadyExists: Name already exists
    

    The error in question is this one

    2020/05/31 14:01:53 ERROR : somefile.pdf: File.Rename error: nameAlreadyExists: Name already exists

    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.

  8. added this to the v1.53 milestone on Jun 2, 2020
  9. changed the title [-]Silent file corruption with rclone mount[/-] [+]vfs: losing data when doing writeback[/+] on Jun 2, 2020
  10. gservat commented on Jul 20, 2020

    @gservat

    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?

  11. ncw commented on Jul 21, 2020

    @ncw
    Member

    I hope this should be fixed in the latest beta if someone wants to try it.

  12. 10 remaining items

  13. modified the milestones: v1.53, v1.54 on Sep 5, 2020
  14. modified the milestones: v1.54, v1.55 on Feb 3, 2021
  15. modified the milestones: v1.55, v1.56 on Apr 3, 2021
  16. modified the milestones: v1.56, v1.57 on Jul 20, 2021
  17. modified the milestones: v1.57, Known Problem on Nov 1, 2021
  18. added 2 commits that reference this issue on Nov 21, 2026
    0f2fef9
    7b1c33c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions