mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
backend/retry: don't trip circuit breaker if context is canceled
When the context used for a load operation is canceled, then the result is always an error independent of whether the file could be retrieved from the backend. Do not false positively trip the circuit breaker in this case. The old behavior was problematic when trying to lock a repository. When `Lock.checkForOtherLocks` listed multiple lock files in parallel and one of them fails to load, then all other loads were canceled. This cancelation was remembered by the circuit breaker, such that locking retries would fail.
This commit is contained in:
@@ -209,9 +209,10 @@ func (be *Backend) Load(ctx context.Context, h backend.Handle, length int, offse
|
||||
return be.Backend.Load(ctx, h, length, offset, consumer)
|
||||
})
|
||||
|
||||
if feature.Flag.Enabled(feature.BackendErrorRedesign) && err != nil && !be.IsPermanentError(err) {
|
||||
if feature.Flag.Enabled(feature.BackendErrorRedesign) && err != nil && ctx.Err() == nil && !be.IsPermanentError(err) {
|
||||
// We've exhausted the retries, the file is likely inaccessible. By excluding permanent
|
||||
// errors, not found or truncated files are not recorded.
|
||||
// errors, not found or truncated files are not recorded. Also ignore errors if the context
|
||||
// was canceled.
|
||||
be.failedLoads.LoadOrStore(key, time.Now())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user