Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack in a gcs retry backoff #2108

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions tempodb/backend/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"time"

"github.com/googleapis/gax-go/v2"
"github.com/grafana/tempo/tempodb/backend/instrumentation"

"cloud.google.com/go/storage"
Expand All @@ -28,6 +29,7 @@ type readerWriter struct {
cfg *Config
bucket *storage.BucketHandle
hedgedBucket *storage.BucketHandle
retryer []storage.RetryOption
}

// NewNoConfirm gets the GCS backend without testing it
Expand Down Expand Up @@ -64,6 +66,15 @@ func internalNew(cfg *Config, confirm bool) (backend.RawReader, backend.RawWrite
cfg: cfg,
bucket: bucket,
hedgedBucket: hedgedBucket,
retryer: []storage.RetryOption{
// Use WithBackoff to change the timing of the exponential backoff.
storage.WithBackoff(gax.Backoff{
Initial: 2 * time.Second,
}),
// Use WithPolicy to configure the idempotency policy. RetryAlways will
// retry the operation even if it is non-idempotent.
storage.WithPolicy(storage.RetryAlways),
},
}

return rw, rw, rw, nil
Expand Down Expand Up @@ -177,7 +188,7 @@ func (rw *readerWriter) Shutdown() {
}

func (rw *readerWriter) writer(ctx context.Context, name string) *storage.Writer {
o := rw.bucket.Object(name)
o := rw.bucket.Object(name).Retryer(rw.retryer...)
w := o.NewWriter(ctx)
w.ChunkSize = rw.cfg.ChunkBufferSize

Expand All @@ -193,7 +204,7 @@ func (rw *readerWriter) writer(ctx context.Context, name string) *storage.Writer
}

func (rw *readerWriter) readAll(ctx context.Context, name string) ([]byte, error) {
r, err := rw.hedgedBucket.Object(name).NewReader(ctx)
r, err := rw.hedgedBucket.Object(name).Retryer(rw.retryer...).NewReader(ctx)
if err != nil {
return nil, err
}
Expand Down