From 9bab947db0921bae50be1ca1dc94a13a9881756a Mon Sep 17 00:00:00 2001 From: zhijian Date: Tue, 16 Jan 2024 13:27:22 +0800 Subject: [PATCH] cmd/sync: increase memory pool for sync oversize files(part > 1G) (#4344) --- pkg/sync/sync.go | 4 ++++ pkg/utils/alloc.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go index 6b0f5c751a7f..169ac4207654 100644 --- a/pkg/sync/sync.go +++ b/pkg/sync/sync.go @@ -444,6 +444,10 @@ func doCopyMultiple(src, dst object.ObjectStorage, key string, size int64, uploa if partSize == 0 { partSize = defaultPartSize } + limits := dst.Limits() + if size > int64(limits.MaxPartSize)*int64(limits.MaxPartCount) { + return fmt.Errorf("object size %d is too large to copy", size) + } if size > partSize*int64(upload.MaxCount) { partSize = size / int64(upload.MaxCount) partSize = ((partSize-1)>>20 + 1) << 20 // align to MB diff --git a/pkg/utils/alloc.go b/pkg/utils/alloc.go index 737398b2ee55..74a7f8642816 100644 --- a/pkg/utils/alloc.go +++ b/pkg/utils/alloc.go @@ -62,8 +62,8 @@ func powerOf2(s int) int { } func init() { - pools = make([]*sync.Pool, 30) // 1 - 1G - for i := 0; i < 30; i++ { + pools = make([]*sync.Pool, 33) // 1 - 8G + for i := 0; i < 33; i++ { func(bits int) { pools[i] = &sync.Pool{ New: func() interface{} {