Skip to content

Commit a2a4c4a

Browse files
committed
change
1 parent dfc9324 commit a2a4c4a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

br/pkg/storage/gcs.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
goerrors "errors"
99
"fmt"
1010
"io"
11+
"net/url"
1112
"os"
1213
"path"
1314
"strings"
@@ -504,6 +505,14 @@ func shouldRetry(err error) bool {
504505
}
505506
}
506507

508+
// workaround for https://github.com/googleapis/google-cloud-go/issues/7090
509+
// seems it's a bug of golang net/http: https://github.com/golang/go/issues/53472
510+
if e := (&url.Error{}); goerrors.As(err, &e) {
511+
if goerrors.Is(e.Err, io.EOF) {
512+
return true
513+
}
514+
}
515+
507516
errMsg := err.Error()
508517
// workaround for strange unknown errors
509518
retryableErrMsg := []string{

br/pkg/storage/gcs_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import (
66
"bytes"
77
"context"
88
"crypto/rand"
9+
goerrors "errors"
910
"flag"
1011
"fmt"
1112
"io"
13+
"net/url"
1214
"os"
1315
"testing"
1416
"time"
@@ -570,3 +572,8 @@ func TestSpeedReadManyFiles(t *testing.T) {
570572
require.NoError(t, eg.Wait())
571573
t.Logf("read %d large files cost %v", len(testFiles), time.Since(now))
572574
}
575+
576+
func TestGCSShouldRetry(t *testing.T) {
577+
require.True(t, shouldRetry(&url.Error{Err: goerrors.New("http2: client connection lost"), Op: "Get", URL: "https://storage.googleapis.com/storage/v1/"}))
578+
require.True(t, shouldRetry(&url.Error{Err: io.EOF, Op: "Get", URL: "https://storage.googleapis.com/storage/v1/"}))
579+
}

0 commit comments

Comments
 (0)