Skip to content

Commit

Permalink
storage/blob/s3: Force a smaller PartSize when blob size is unknown
Browse files Browse the repository at this point in the history
Blob size would be unknown ahead of time if message store compression is used (e.g. in imapsql).

Part of #395 fix
  • Loading branch information
foxcpp committed Aug 28, 2021
1 parent 14a441f commit fc00133
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/storage/blob/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,16 @@ func (s *Store) Create(ctx context.Context, key string, blobSize int64) (module.
errCh := make(chan error, 1)

go func() {
_, err := s.cl.PutObject(ctx, s.bucketName, s.objectPrefix+key, pr, blobSize, minio.PutObjectOptions{})
partSize := uint64(0)
if blobSize == module.UnknownBlobSize {
// Without this, minio-go will allocate 500 MiB buffer which
// is a little too much.
// https://github.com/minio/minio-go/issues/1478
partSize = 1 * 1024 * 1024 /* 1 MiB */
}
_, err := s.cl.PutObject(ctx, s.bucketName, s.objectPrefix+key, pr, blobSize, minio.PutObjectOptions{
PartSize: partSize,
})
if err != nil {
pr.CloseWithError(fmt.Errorf("s3 PutObject: %w", err))
}
Expand Down

0 comments on commit fc00133

Please sign in to comment.