Skip to content

Commit

Permalink
Merge pull request #740 from rodrigargar/respect-s3-max-parts-count
Browse files Browse the repository at this point in the history
respect max_parts_count
  • Loading branch information
Slach authored Sep 7, 2023
2 parents 94b0b42 + 0504c8f commit 76e1e08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/storage/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,9 @@ func NewBackupDestination(ctx context.Context, cfg *config.Config, ch *clickhous
// https://github.com/Altinity/clickhouse-backup/issues/317
if bufferSize <= 0 {
bufferSize = int(cfg.General.MaxFileSize) / cfg.AzureBlob.MaxPartsCount
if int(cfg.General.MaxFileSize) % cfg.AzureBlob.MaxPartsCount > 0 {
bufferSize++
}
if bufferSize < 2*1024*1024 {
bufferSize = 2 * 1024 * 1024
}
Expand All @@ -652,6 +655,9 @@ func NewBackupDestination(ctx context.Context, cfg *config.Config, ch *clickhous
partSize := cfg.S3.PartSize
if cfg.S3.PartSize <= 0 {
partSize = cfg.General.MaxFileSize / cfg.S3.MaxPartsCount
if cfg.General.MaxFileSize % cfg.S3.MaxPartsCount > 0 {
partSize++
}
if partSize < 5*1024*1024 {
partSize = 5 * 1024 * 1024
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/storage/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,11 @@ func (s *S3) CopyObject(ctx context.Context, srcBucket, srcKey, dstKey string) (

// Set the part size (e.g., 5 MB)
partSize := srcSize / s.Config.MaxPartsCount
if srcSize % s.Config.MaxPartsCount > 0 {
partSize++
}
if partSize < 5*1024*1024 {
partSize = 5 * 1014 * 1024
partSize = 5 * 1024 * 1024
}

// Calculate the number of parts
Expand Down

0 comments on commit 76e1e08

Please sign in to comment.