Skip to content

Commit

Permalink
Merge pull request #80947 from cockroachdb/blathers/backport-release-…
Browse files Browse the repository at this point in the history
…22.1-80668

release-22.1: gcp,s3,azure: make the storage client upload chunk size configurable
  • Loading branch information
adityamaru authored Jun 28, 2022
2 parents 29265df + 147bd0a commit f23d710
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/cloud/amazon/s3_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ func newClient(
sess.Config.Region = aws.String(region)

c := s3.New(sess)
u := s3manager.NewUploader(sess)
u := s3manager.NewUploader(sess, func(uploader *s3manager.Uploader) {
uploader.PartSize = cloud.WriteChunkSize.Get(&settings.SV)
})
return s3Client{client: c, uploader: u}, region, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/azure/azure_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (s *azureStorage) Writer(ctx context.Context, basename string) (io.WriteClo
defer sp.Finish()
_, err := azblob.UploadStreamToBlockBlob(
ctx, r, blob, azblob.UploadStreamToBlockBlobOptions{
BufferSize: 4 << 20,
BufferSize: int(cloud.WriteChunkSize.Get(&s.settings.SV)),
},
)
return err
Expand Down
9 changes: 9 additions & 0 deletions pkg/cloud/cloud_io.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ var httpCustomCA = settings.RegisterStringSetting(
"",
).WithPublic()

// WriteChunkSize is used to control the size of each chunk that is buffered and
// uploaded by the cloud storage client.
var WriteChunkSize = settings.RegisterByteSizeSetting(
settings.TenantWritable,
"cloudstorage.write_chunk.size",
"controls the size of each file chunk uploaded by the cloud storage client",
8<<20,
)

// HTTPRetryOptions defines the tunable settings which control the retry of HTTP
// operations.
var HTTPRetryOptions = retry.Options{
Expand Down
1 change: 1 addition & 0 deletions pkg/cloud/gcp/gcs_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (g *gcsStorage) Writer(ctx context.Context, basename string) (io.WriteClose
path.Join(g.prefix, basename))})

w := g.bucket.Object(path.Join(g.prefix, basename)).NewWriter(ctx)
w.ChunkSize = int(cloud.WriteChunkSize.Get(&g.settings.SV))
if !gcsChunkingEnabled.Get(&g.settings.SV) {
w.ChunkSize = 0
}
Expand Down

0 comments on commit f23d710

Please sign in to comment.