From 404c51b8d55d95261a6782b0ca32ac72ca5464bf Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 4 Dec 2025 22:47:01 -0800 Subject: [PATCH] filer: restore fallback to chunkCache when cacher returns no data Fix critical issue where ReadChunkAt would return 0,nil immediately if SingleChunkCacher couldn't provide data for the requested offset, without trying the chunkCache fallback. Now if cacher.readChunkAt returns n=0 and err=nil, we fall through to try chunkCache. --- weed/filer/reader_cache.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/weed/filer/reader_cache.go b/weed/filer/reader_cache.go index 160dcc974..8f2b66231 100644 --- a/weed/filer/reader_cache.go +++ b/weed/filer/reader_cache.go @@ -99,7 +99,13 @@ func (rc *ReaderCache) ReadChunkAt(ctx context.Context, buffer []byte, fileId st if cacher, found := rc.downloaders[fileId]; found { rc.Unlock() - return cacher.readChunkAt(ctx, buffer, offset) + n, err := cacher.readChunkAt(ctx, buffer, offset) + if n > 0 || err != nil { + return n, err + } + // If n=0 and err=nil, the cacher couldn't provide data for this offset. + // Fall through to try chunkCache. + rc.Lock() } if shouldCache || rc.lookupFileIdFn == nil { n, err := rc.chunkCache.ReadChunkAt(buffer, fileId, uint64(offset))