1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 07:43:03 +00:00

Merge pull request #5014 from MichaelEischer/configurable-slow-request-timeout

Make timeout for slow requests configurable
This commit is contained in:
Michael Eischer 2024-08-29 16:52:24 +02:00 committed by GitHub
commit 7bbf75237d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 1 deletions

View file

@ -0,0 +1,13 @@
Enhancement: Make timeout for stuck requests customizable
Restic monitors connections to the backend to detect stuck requests. If a request
does not return any data within five minutes, restic assumes the request is stuck and
retries it. However, for large repositories it sometimes takes longer than that to
collect a list of all files, causing the following error:
`List(data) returned error, retrying after 1s: [...]: request timeout`
It is now possible to increase the timeout using the `--stuck-request-timeout` option.
https://github.com/restic/restic/issues/4970
https://github.com/restic/restic/pull/5014

View file

@ -140,6 +140,7 @@ func init() {
f.UintVar(&globalOptions.PackSize, "pack-size", 0, "set target pack `size` in MiB, created pack files may be larger (default: $RESTIC_PACK_SIZE)")
f.StringSliceVarP(&globalOptions.Options, "option", "o", []string{}, "set extended option (`key=value`, can be specified multiple times)")
f.StringVar(&globalOptions.HTTPUserAgent, "http-user-agent", "", "set a http user agent for outgoing http requests")
f.DurationVar(&globalOptions.StuckRequestTimeout, "stuck-request-timeout", 5*time.Minute, "`duration` after which to retry stuck requests")
// Use our "generate" command instead of the cobra provided "completion" command
cmdRoot.CompletionOptions.DisableDefaultCmd = true

View file

@ -228,3 +228,17 @@ Restic backup command fails to find a valid file in Windows
If the name of a file in Windows contains an invalid character, Restic will not be
able to read the file. To solve this issue, consider renaming the particular file.
What can I do in case of "request timeout" errors?
--------------------------------------------------
Restic monitors connections to the backend to detect stuck requests. If a request
does not return any data within five minutes, restic assumes the request is stuck and
retries it. However, for large repositories it sometimes takes longer than that to
collect a list of all files, causing the following error:
::
List(data) returned error, retrying after 1s: [...]: request timeout
In this case you can increase the timeout using the ``--stuck-request-timeout`` option.

View file

@ -31,6 +31,9 @@ type TransportOptions struct {
// Specify Custom User-Agent for the http Client
HTTPUserAgent string
// Timeout after which to retry stuck requests
StuckRequestTimeout time.Duration
}
// readPEMCertKey reads a file and returns the PEM encoded certificate and key
@ -143,7 +146,11 @@ func Transport(opts TransportOptions) (http.RoundTripper, error) {
}
if feature.Flag.Enabled(feature.BackendErrorRedesign) {
rt = newWatchdogRoundtripper(rt, 5*time.Minute, 128*1024)
if opts.StuckRequestTimeout == 0 {
opts.StuckRequestTimeout = 5 * time.Minute
}
rt = newWatchdogRoundtripper(rt, opts.StuckRequestTimeout, 128*1024)
}
// wrap in the debug round tripper (if active)