Skip to content

Use part files for cross-storage move/copy #13379

Closed

Description

@PVince81

Consider the following steps:

  1. Mount SMB storage as "/smb"
  2. Upload a file "huge.dat" to "/"
  3. Move "/huge.dat" into "/smb"

Since we're in a cross-storage situation, the rename/move operation will internally do a stream copy of "/huge.dat" into "/smb/huge.dat".
This means that for a short time we have a partial file on the target storage which might be picked up by a running scanner or other people.

One idea would be to first copy the file from "/huge.dat" to "/smb/huge.dat.transactionId.part". Then if the copy succeeded, rename the part file to the final file, just like it's done for regular uploads.
But in this case it's an "internal upload" between storages.

I noticed this while investigating the "preserve file id cross storage" case.
Currently the target file isn't finished, but there is already a cache entry for it with zero size. I'd expect the cache entry to only appear once the transfer is completely finished. (and if you run ./occ files:scan during the transfer, that cache entry will have the partial size of the file)

@icewind1991 @DeepDiver1975 what do you think ?

Activity

  1. PVince81 commented on Jan 21, 2015

    @PVince81
    ContributorAuthor

    We already have these checks during WebDAV upload (expected size, etc) and rename after a full upload, and only if the file is completely uploaded. Why not reuse the same logic for cross storage copy/upload to add the same kind of robustness ?

    We could move that logic into a generic class or storage handler (a bit like the chunk handler but for part files) and have the verification code there.

  2. DeepDiver1975 commented on Jan 21, 2015

    @DeepDiver1975
    Contributor

    Sounds reasonable to me - looks like part files will become more and more important - some days back we had the idea to fully remove them.

    What comes to my mind here are higher-level-transactions/locks - this might me a solution as well.

  3. PVince81 commented on Jan 21, 2015

    @PVince81
    ContributorAuthor

    High level locks might help for storages that OC control.
    But if the storage is external and used outside of OC (ex: SMB), part files can help to not overwrite the final file too early as we do now.

  4. DeepDiver1975 commented on Jan 21, 2015

    @DeepDiver1975
    Contributor

    High level locks might help for storages that OC control.
    But if the storage is external and used outside of OC (ex: SMB), part files can help to not overwrite the final file too early as we do now.

    indeed - I was more thinking about the getting-ignored-by-scanner requirement. Overwrite is to be handled by part files - true.

  5. modified the milestone: backlog on Mar 21, 2015
  6. PVince81 commented on Jun 24, 2015

    @PVince81
    ContributorAuthor

    Another test case I observed:

    1. Mount SFTP storage to "/sftp"
    2. Upload a huge file (150MB) into "/sftp/data1.dat"
    3. Upload a small file (8kb) into "/sftp/data1.dat" (overwrite)

    Even though the file is very small, it takes a long time to upload because in the background the trashbin is downloading the huge file to trash before replacing it.

    Here we could first rename the old "data1.dat" to "data1.dat.todelete.part", put the new file and then download the part file to trash. Maybe the download could be done in a bkg job instead.

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