mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-27 07:20:44 +01:00
filer: bound format chunk sizes when no maxMB is configured
Extent chunks are buffered in memory, so an absent limit must not mean unlimited. Also close the repack chunk reader to release its private reader cache, and drop the arithmetic capacity hint on the extended-map allocation.
This commit is contained in:
1 parent
4bf126944f
commit
7387866fd6
1 file changed
+9
-1
@@ -28,6 +28,9 @@ import (
|
||||
const (
|
||||
maxFormatSidecarBytes = 16 << 20
|
||||
formatSniffBytes = 512
|
||||
// defaultFormatChunkSizeMB caps extent chunks when no maxMB is configured.
|
||||
// Extent chunks are buffered in memory, so the limit must never be absent.
|
||||
defaultFormatChunkSizeMB = 4
|
||||
)
|
||||
|
||||
// formatChunkSizeLimit mirrors the autoChunk maxMB resolution.
|
||||
@@ -37,6 +40,9 @@ func (fs *FilerServer) formatChunkSizeLimit(r *http.Request) int64 {
|
||||
if maxMB <= 0 && fs.option.MaxMB > 0 {
|
||||
maxMB = int32(fs.option.MaxMB)
|
||||
}
|
||||
if maxMB <= 0 {
|
||||
maxMB = defaultFormatChunkSizeMB
|
||||
}
|
||||
return int64(maxMB) * 1024 * 1024
|
||||
}
|
||||
|
||||
@@ -261,6 +267,8 @@ func (fs *FilerServer) formatRepack(ctx context.Context, w http.ResponseWriter,
|
||||
chunkViews := filer.ViewFromChunks(ctx, lookup, oldChunks, 0, size)
|
||||
readerCache := filer.NewReaderCache(8, chunk_cache.NewChunkCacheInMemory(16), lookup, nil)
|
||||
readerAt := filer.NewChunkReaderAtFromClient(ctx, readerCache, chunkViews, size, filer.DefaultPrefetchCount)
|
||||
// Close releases the private reader cache and its in-flight prefetches.
|
||||
defer readerAt.Close()
|
||||
|
||||
hint := format.Hint{Name: entry.Name(), ContentType: entry.Attr.Mime, Size: size}
|
||||
sniffSize := int64(formatSniffBytes)
|
||||
@@ -321,7 +329,7 @@ func (fs *FilerServer) formatRepack(ctx context.Context, w http.ResponseWriter,
|
||||
|
||||
newEntry := *entry
|
||||
newEntry.Chunks = newChunks
|
||||
newEntry.Extended = make(map[string][]byte, len(entry.Extended)+1)
|
||||
newEntry.Extended = make(map[string][]byte)
|
||||
for k, v := range entry.Extended {
|
||||
newEntry.Extended[k] = v
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user