Skip to content

Commit 002ba34

Browse files
committed
fix S3 multipart operations to respect
1 parent 1f67af3 commit 002ba34

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v2.6.42
2+
BUG FIXES
3+
- fix S3 multipart operations (upload, download, copy) to respect `S3_MAX_PARTS_COUNT` instead of hardcoded 10000 value, allows S3-compatible backends with stricter limits
4+
15
# v2.6.41
26
BUG FIXES
37
- improve restore long RBAC which have length more 64k, fix [1305](https://github.com/Altinity/clickhouse-backup/issues/1305)

pkg/storage/s3.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func (s *S3) GetFileReaderWithLocalPath(ctx context.Context, key, localPath stri
258258
downloader.Concurrency = s.Concurrency
259259
downloader.BufferProvider = s3manager.NewPooledBufferedWriterReadFromProvider(s.BufferSize)
260260
var partSize int64
261-
if s.Config.ChunkSize > 0 && (remoteSize+s.Config.ChunkSize-1)/s.Config.ChunkSize < 10000 {
261+
if s.Config.ChunkSize > 0 && (remoteSize+s.Config.ChunkSize-1)/s.Config.ChunkSize < s.Config.MaxPartsCount {
262262
// Use configured chunk size
263263
partSize = s.Config.ChunkSize
264264
} else {
@@ -334,7 +334,7 @@ func (s *S3) PutFileAbsolute(ctx context.Context, key string, r io.ReadCloser, l
334334
uploader.Concurrency = s.Concurrency
335335
uploader.BufferProvider = s3manager.NewBufferedReadSeekerWriteToPool(s.BufferSize)
336336
var partSize int64
337-
if s.Config.ChunkSize > 0 && (localSize+s.Config.ChunkSize-1)/s.Config.ChunkSize < 10000 {
337+
if s.Config.ChunkSize > 0 && (localSize+s.Config.ChunkSize-1)/s.Config.ChunkSize < s.Config.MaxPartsCount {
338338
partSize = s.Config.ChunkSize
339339
} else {
340340
partSize = localSize / s.Config.MaxPartsCount
@@ -546,7 +546,7 @@ func (s *S3) CopyObject(ctx context.Context, srcSize int64, srcBucket, srcKey, d
546546

547547
// Set the part size (128 MB minimum for CopyObject, or use configured chunk size)
548548
var partSize int64
549-
if s.Config.ChunkSize > 0 && (srcSize+s.Config.ChunkSize-1)/s.Config.ChunkSize < 10000 {
549+
if s.Config.ChunkSize > 0 && (srcSize+s.Config.ChunkSize-1)/s.Config.ChunkSize < s.Config.MaxPartsCount {
550550
partSize = s.Config.ChunkSize
551551
} else {
552552
partSize = srcSize / s.Config.MaxPartsCount

0 commit comments

Comments
 (0)