Skip to content

Commit

Permalink
respect max_parts_count #739
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigargar committed Sep 5, 2023
1 parent d74482e commit fdff13b
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 fdff13b

Please sign in to comment.