From 1905ecc8d62fe84b01bcd78854191c5b8e92e734 Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Wed, 19 Mar 2025 22:32:26 +0800 Subject: [PATCH] Replace `jpillora/backoff` with `cenkalti/backoff/v4` A drop-in replacement. Signed-off-by: Eng Zer Jun --- go/Godeps/LICENSES | 28 ---------------------------- go/go.mod | 1 - go/go.sum | 1 - go/store/nbs/s3_object_reader.go | 16 ++++++++-------- 4 files changed, 8 insertions(+), 38 deletions(-) diff --git a/go/Godeps/LICENSES b/go/Godeps/LICENSES index 4080cf5fed6..1fa10c70a0e 100644 --- a/go/Godeps/LICENSES +++ b/go/Godeps/LICENSES @@ -10942,34 +10942,6 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice = LICENSE 2170ba25b6b80176137bcc25679ebf4b2cbb38b83049c8c62658cd52 = ================================================================================ -================================================================================ -= github.com/jpillora/backoff licensed under: = - -The MIT License (MIT) - -Copyright (c) 2017 Jaime Pillora - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - -= LICENSE 83831995a7e93db77f95ee20af5603b91e303ef348cb9bde1b13c8c0 = -================================================================================ - ================================================================================ = github.com/juju/gnuflag licensed under: = diff --git a/go/go.mod b/go/go.mod index fdbfb95dbdc..b647048bab8 100644 --- a/go/go.mod +++ b/go/go.mod @@ -22,7 +22,6 @@ require ( github.com/gocraft/dbr/v2 v2.7.2 github.com/golang/snappy v0.0.4 github.com/google/uuid v1.6.0 - github.com/jpillora/backoff v1.0.0 github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d github.com/mattn/go-isatty v0.0.17 github.com/mattn/go-runewidth v0.0.13 diff --git a/go/go.sum b/go/go.sum index d9442468c42..b9a6424658a 100644 --- a/go/go.sum +++ b/go/go.sum @@ -456,7 +456,6 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfC github.com/jmoiron/sqlx v1.3.4 h1:wv+0IJZfL5z0uZoUjlpKgHkgaFSYD+r9CfrXjEXsO7w= github.com/jmoiron/sqlx v1.3.4/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= diff --git a/go/store/nbs/s3_object_reader.go b/go/store/nbs/s3_object_reader.go index 510dd74d7d5..a419e3cd0e4 100644 --- a/go/store/nbs/s3_object_reader.go +++ b/go/store/nbs/s3_object_reader.go @@ -37,7 +37,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/jpillora/backoff" + "github.com/cenkalti/backoff/v4" "golang.org/x/sync/errgroup" ) @@ -144,14 +144,14 @@ func (s3or *s3ObjectReader) readRange(ctx context.Context, name string, p []byte // We hit the point of diminishing returns investigating #3255, so add retries. In conversations with AWS people, it's not surprising to get transient failures when talking to S3, though SDKs are intended to have their own retrying. The issue may be that, in Go, making the S3 request and reading the data are separate operations, and the SDK kind of can't do its own retrying to handle failures in the latter. if isConnReset(err) { // We are backing off here because its possible and likely that the rate of requests to S3 is the underlying issue. - b := &backoff.Backoff{ - Min: 128 * time.Microsecond, - Max: 1024 * time.Millisecond, - Factor: 2, - Jitter: true, - } + b := backoff.NewExponentialBackOff() + b.InitialInterval = 128 * time.Millisecond + b.MaxInterval = 1024 * time.Millisecond + b.Multiplier = 2 + b.Reset() + for ; isConnReset(err); n, sz, err = read() { - dur := b.Duration() + dur := b.NextBackOff() time.Sleep(dur) } }