Closes #932 `connect-timeout` gets replaced by an exponential backoff for the download timeout where the initial value is controlled by the setting `initial-connect-timeout`. Per iteration, the upper limit of the timeout is increased set to timeout := min(max_connect_timeout, initial_connect_timeout * 2^i) I decided to move the entire timeout / tracking of attempts into its own class to not make the filetransfer implementation more complex. Also, that allows us to write unit-tests for it. Setting `--download-attempts` to `0` is forbidden now and an exception will be thrown. For `--offline` we set it to `1`, the behavior is equivalent to what it was before: whether the max tries were exceeded is only checked after the first download exception got thrown, i.e. there's still one attempt being made. The end-result - with timeouts being caused by a wrongly set proxy - looks like this: $ env HTTPS_PROXY=1.1.1.1 nix store ping --store https://example.com warning: error: unable to download 'https://example.com/nix-cache-info': Connection timed out after 5006 milliseconds (curl error code=28); retrying in 422ms ms (attempt 1/5) warning: error: unable to download 'https://example.com/nix-cache-info': Connection timed out after 10010 milliseconds (curl error code=28); retrying in 1003ms ms (attempt 2/5) warning: error: unable to download 'https://example.com/nix-cache-info': Connection timed out after 20020 milliseconds (curl error code=28); retrying in 2018ms ms (attempt 3/5) warning: error: unable to download 'https://example.com/nix-cache-info': Connection timed out after 40007 milliseconds (curl error code=28); retrying in 4087ms ms (attempt 4/5) error: unable to download 'https://example.com/nix-cache-info': Connection timed out after 80074 milliseconds (curl error code=28) Change-Id: I9e8d08d78275bcf60080d663febc9e075243d36b
428 B
428 B
synopsis, issues, cls, category, credits
| synopsis | issues | cls | category | credits | |||
|---|---|---|---|---|---|---|---|
| libstore: exponential backoff for downloads |
|
|
Fixes |
|
The connection timeout when downloading from e.g. a binary cache is exponentially
increased per failure. The option connect-timeout is now an alias to max-connect-timeout
which is the maximum value for a timeout. The start value is controlled
by initial-connect-timeout which is 5 by default.