Retry logic to treat no space errors permanently

Handle local disk space errors as permanent errors in retry logic.
This commit is contained in:
Michael Mendy 2026-05-25 08:27:42 -07:00 committed by GitHub
parent 3962aee507
commit 2e231a6f29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -107,7 +107,6 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error
bo := backoff.NewExponentialBackOff()
bo.MaxElapsedTime = be.MaxElapsedTime
if feature.Flag.Enabled(feature.BackendErrorRedesign) {
bo.InitialInterval = 1 * time.Second
bo.Multiplier = 2
@ -135,14 +134,25 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error
err := retryNotifyErrorWithSuccess(
func() error {
err := f()
// Running out of local disk space is not a transient backend
// failure. For example, `restic check` can fail while writing to a
// temporary cache directory. Retrying only repeats the same local
// disk-space error.
if isNoSpaceError(err) {
return backoff.Permanent(err)
}
// don't retry permanent errors as those very likely cannot be fixed by retrying
// TODO remove IsNotExist(err) special cases when removing the feature flag
if feature.Flag.Enabled(feature.BackendErrorRedesign) && !errors.Is(err, &backoff.PermanentError{}) && be.Backend.IsPermanentError(err) {
permanentErrorAttempts--
}
if permanentErrorAttempts <= 0 {
return backoff.Permanent(err)
}
return err
},
backoff.WithContext(b, ctx),