rustbuild seems to deal badly with poor internet connections

Created on 8 Apr 2016  路  14Comments  路  Source: rust-lang/rust

I tried to build rust with rustbuild.

./configure --enable-ccache --enable-rustbuild
make

But after a few seconds it fails downloading the nightly with errno 104, which is connection reset by peer. If I run it again it sees the file is there and fails saying the checksum is wrong. I guess it needs to retry the download.

A-rustbuild E-easy

All 14 comments

Ah we probably need to download to a temporary location and only when done move it over into where it's expected to be, that way we'll restart any failed download.

Hi ! Anyone interested in taking this ? If not I'd like to try.

@cyplo: Sure. Take it.

If you have any questions, feel free to ask me @cyplo!

Hi @alexcrichton, using your invite to ask here ;)

I took a quick look there and it seems that the initial download is done via bootstrap.py and it seems that the fix can be done entirely within that file.

Do you maybe know if there any other downloads, not done during the bootstrap.py phase that would need this treatment or other reasons to touch something beyond bootstrap.py in the fix for this issue ?

Thanks a lot !

Yeah I believe that's the only location where we download anything. There's other downloads that Cargo does for the actual compilation of the build system itself but Cargo handles bad internet and things like that internally already.

Hi ! I see that #32926 is merged now, I'm thinking on how to integrate the download resume/retry with it. @alexcrichton / @caipre Let me know what do you think of the following:

  • try downloading to a temp location
  • check checksum there
  • if invalid - remove and retry max N times
  • if valid - move to destination

Isn't it possible to check checksum before downloading? It seems to be overkill otherwise (downloading something to just get "no, you're up to date finally" is really annoying). Or at least check the date or something equivalent which could prevent to download for nothing?

Yes, totally, it would probably be like this:

  • if there is no file - download
  • check checksum
  • invalid - retry from scratch
  • valid - proceed

thanks !

The logic to check whether the file exists and needs updated is already present: https://github.com/rust-lang/rust/blob/6fa61b810dc95ca3e8bbda1681229f855f214fc4/src/bootstrap/bootstrap.py#L92-L93

My PR added the checksumming within the get() method, so you shouldn't have any work on that point. I'm not sure we need a retry mechanism. I prefer to just report the problem and let the user decide what to do next.

For this issue, you need to change the path that the tarball is downloaded to to use some temporary path, then move that to the correct path after the download is complete.

An analogy to shell:

curl -o file.tmp https://... && mv file.tmp file

I suppose you might want to update the checksumming to be done on the temporary file, and only if that succeeds do the move.

Yeah @caipre's thoughts are exactly my own, let's download to a temp location, verify the checksum, and once both are done we move it to the final location.

Hey ! I need some more time to get to PR, as I'm quite tight on time lately. If it's not critical/needed quickly - I will come up with PR eventually. If it is - feel free to grab it.

Hi ! @durka: the fix should be merged now, could you see if this helps ? thanks !

Closing as #33288 has landed, but feel free to reopen if troubles still happen!

(thanks again @cyplo!)

Was this page helpful?
0 / 5 - 0 ratings