2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 19:38:57 +00:00

backend/retry: feature flag new retry behavior

This commit is contained in:
Michael Eischer 2024-05-24 20:16:58 +02:00
parent 723247c8e5
commit e4a48085ae

View File

@ -108,9 +108,10 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error
bo := backoff.NewExponentialBackOff()
bo.MaxElapsedTime = be.MaxElapsedTime
bo.InitialInterval = 1 * time.Second
bo.Multiplier = 2
if feature.Flag.Enabled(feature.BackendErrorRedesign) {
bo.InitialInterval = 1 * time.Second
bo.Multiplier = 2
}
if fastRetries {
// speed up integration tests
bo.InitialInterval = 1 * time.Millisecond
@ -120,6 +121,12 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error
}
}
var b backoff.BackOff = withRetryAtLeastOnce(bo)
if !feature.Flag.Enabled(feature.BackendErrorRedesign) {
// deprecated behavior
b = backoff.WithMaxRetries(b, 10)
}
err := retryNotifyErrorWithSuccess(
func() error {
err := f()
@ -130,7 +137,7 @@ func (be *Backend) retry(ctx context.Context, msg string, f func() error) error
}
return err
},
backoff.WithContext(withRetryAtLeastOnce(bo), ctx),
backoff.WithContext(b, ctx),
func(err error, d time.Duration) {
if be.Report != nil {
be.Report(msg, err, d)