Skip to content

FTP upload and download for big files (over 10GB) fails #5328

Closed

Description

@jcn50

Output of rclone version

rclone: Version "v1.55.1"

Describe the issue

This happens only for big files (over 10GB): the upload goes to 100% then rclone disconnects, reconnects to check the file on destination but declares that the upload has failed and restarts it! Adding --no-check-dest --low-level-retries 1 does not resolve the issue.

It works when uploading manually with the ftp command! So the issue is NOT with the FTP server!

Typical rclone log/verbose going into a loop:

2021-05-13 18:34:22 DEBUG : big.zip: Need to transfer - File not found at Destination
2021-05-13 18:44:53 DEBUG : ftp://server.com:21/: Connecting to FTP server
2021-05-13 18:44:54 DEBUG : big.zip: Removed after failed upload: read tcp IP1:37706->IP2:21: i/o timeout
2021-05-13 18:44:54 DEBUG : big.zip: Received error: update stor: read tcp IP1:37706->IP2:21: i/o timeout - low level retry 1/10

I suspect the FTP library to be behind this bug: there is no timeout issue, I can see the file going to 100% on the FTP destination before it gets deleted by rclone. TLS is not used.

My suggestions/questions to fix:
a) Why does rclone disconnects + reconnects to check the file instead of using the same FTP session?
b) Can't rclone sleeps for 2-3 seconds before doing the check of the uploaded file?

=> see log with --dump bodies attached!
rclone_issue_5328.txt

Activity

  1. ncw commented on May 14, 2021

    @ncw
    Member

    a) Why does rclone disconnects + reconnects to check the file instead of using the same FTP session?

    Good idea...

    In the code you linked, rclone could open a new connection and check the size of the file. It if was as expected then it could leave it alone rather than deleting it.

    Fancy sending a pull request to fix?

    b) Can't rclone sleeps for 2-3 seconds before doing the check of the uploaded file?

    Why do you think that would help?

  2. jcn50 commented on May 14, 2021

    @jcn50
    Author

    Fancy sending a pull request to fix?

    Sorry this is above my abilities 😞

    Why do you think that would help?

    In the FTP library code referenced in my first post: the author has a sleep time that may be too low/small.

  3. added this to the Help Wanted milestone on May 15, 2021
  4. jcn50 commented on May 15, 2021

    @jcn50
    Author

    I had a second look at this, and I think the bug is somewhere else: rclone is not reading the reply from the FTP server! If you look at the --dump bodies one:

    2021/05/13 22:32:53 DEBUG : FTP Rx: "150 Accepted data connection"
    2021/05/13 22:32:52 DEBUG : FTP Tx: "QUIT"
    

    but it should be like this:

    2021/05/13 22:32:53 DEBUG : FTP Rx: "150 Accepted data connection"
    2021/05/13 22:32:52 DEBUG : FTP Rx: "226-File successfully transferred"
    2021/05/13 22:32:53 DEBUG : FTP Tx: "QUIT"
    

    I don't know why rclone is not waiting for that 226 code reply?

  5. jcn50 commented on May 16, 2021

    @jcn50
    Author

    Guys: there is an issue with the download as well. It's the same as #4622

  6. jcn50 commented on May 16, 2021

    @jcn50
    Author

    @ivandeex can you re-tag this issue as bug?.. I think it needs to be looked after urgently~ I know that you have raised another issue with that FTP library too ( #5283 ) I wonder why curl isn't used for FTP?... It will be less buggy than this library~

  7. changed the title [-]FTP upload for big files (over 10GB) fails[/-] [+]FTP upload and download for big files (over 10GB) fails[/+] on May 16, 2021
  8. jcn50 commented on May 16, 2021

    @jcn50
    Author

    I do not know how to make a pull request, I do not understand.

    I think a sleep needs to be added just before the Update() function is called:

    func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error) {
    	// fs.Debugf(f, "Trying to put file %s", src.Remote())
    	err := f.mkParentDir(ctx, src.Remote())
    	if err != nil {
    		return nil, errors.Wrap(err, "Put mkParentDir failed")
    	}
    	o := &Object{
    		fs:     f,
    		remote: src.Remote(),
    	}
    	time.Sleep(1 * time.Second)
    	err = o.Update(ctx, in, src, options...)
    	return o, err
    }
    
  9. 17 remaining items

  10. ncw commented on May 18, 2021

    @ncw
    Member

    This problem exists with curl too:
    https://stackoverflow.com/questions/63214142/epsv-mode-always-fails-in-curl-when-connecting-over-ftps

    Your connection transferred the data though didn't it?

    Both of my servers were on IPv4, I see no reasons why EPSV should be enabled anyway. I think there are and there will be others with the same problem. Thus my advice to disable it by default. The exact rule is: if one of the server is on IPv4 only (client or remote), then EPSV should be disabled.

    I'm glad you made it work :-)

    We have the disable EPSV option for those that require it, but for the vast majority of users it works fine.

  11. jcn50 commented on May 18, 2021

    @jcn50
    Author

    Your connection transferred the data though didn't it?

    Yes~

    We have the disable EPSV option for those that require it, but for the vast majority of users it works fine.

    OK np

  12. ncw commented on May 18, 2021

    @ncw
    Member

    OK, I'm going to close this now as I think we've arrived at a solution and the issue will be searchable for anyone having the same problem.

    Thanks

  13. ivandeex commented on Jul 28, 2021

    @ivandeex
    Member

    I encountered similar problem and investigated.
    I'm now 100% sure we hit rclone bug with ftp timeouts!

    @ncw
    bug description follows:

    • jlaffaye/ftp makes control/data streams from a factory provided by rclone. this factory wraps go tcp streams in the code which cancels streams after timeout but resets timeout timer after each read/write.
    • a typical ftp upload is: client talks with ftp server on control stream, sets upload parameters, then create one or more data streams and do the upload (this can be long), then return to control stream and ask ftp server about upload results (here be dragons)
    • while client was busy uploading on data stream, the control stream timeout happened and client's attempt to read status returned I/O timeout

    @ncw
    preliminary fix for:

    @jcn50
    Do you want to try experimental fix? It's here:
    https://github.com/ivandeex/rclone/releases/tag/v1.56.0-ftp08

  14. self-assigned this
    on Jul 28, 2021
  15. modified the milestones: Help Wanted, v1.57 on Jul 28, 2021
  16. ncw commented on Jul 28, 2021

    @ncw
    Member

    @ivandeex wrote:

    I encountered similar problem and investigated.
    I'm now 100% sure we hit rclone bug with ftp timeouts!

    Ah ha!

    bug description follows:

    • jlaffaye/ftp makes control/data streams from a factory provided by rclone. this factory wraps go tcp streams in the code which cancels streams after timeout but resets timeout timer after each read/write.
    • a typical ftp upload is: client talks with ftp server on control stream, sets upload parameters, then create one or more data streams and do the upload (this can be long), then return to control stream and ask ftp server about upload results (here be dragons)
    • while client was busy uploading on data stream, the control stream timeout happened and client's attempt to read status returned I/O timeout

    OK that makes sense.

    preliminary fix for:

    The deadline will be reset if we get data on the stream. I guess that is your intention.

    LGTM :-)

  17. linked a pull request that will close this issueftp: fix I/O timeout after long uploads #5596on Sep 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions