filer: fail the request, not the process, when chunks cannot be resolved (#11685)

* filer: fail the request, not the process, when chunks cannot be resolved

CompactFileChunks and ViewFromChunks discarded the error from
NonOverlappingVisibleIntervals and iterated the nil interval list it
returns on failure. A CreateEntry or UpdateEntry whose context was
cancelled therefore panicked in SeparateGarbageChunks and took the whole
filer down, losing the metadata log it had not yet flushed.

Both functions now return the error. cleanupChunks fails the request
with it, the mount flush paths return it, the replication sinks and the
S3 SSE range reader return it, and a ChunkStreamReader that cannot build
its view fails every read with it and reports it as its SourceError
instead of reading as an empty file.

Fixes #11682

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* filer: propagate chunk resolution failures in scan paths

NonOverlappingVisibleIntervals can fail without a cancelled context; the
query engine and log-store callers discarded the error and dereferenced
nil intervals.

* query: propagate chunk resolution errors instead of skipping files

When a manifest cannot be resolved, ReadParquetStatistics,
countLiveLogRowsExcludingParquetSources, and computeLiveLogMinMax logged a
warning and skipped the failed file, so queries returned understated counts
and wrong min/max values. Surface the errors instead: the fast-path
aggregation collector now returns a DataSourceError so the engine falls
back to a full scan, and the row-count helpers return the error rather
than a partial total.

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-10 23:39:29 +08:00
1 parent 774c9927a7
commit b2eefb8a73
20 files changed
+271 -65

No files matched your search

+4 -1
View File
@@ -803,7 +803,10 @@ func (fs *FilerServer) cleanupChunks(ctx context.Context, fullpath string, exist
// files with manifest chunks are usually large and append only, skip calculating covered chunks
manifestChunks, nonManifestChunks := filer.SeparateManifestChunks(newEntry.GetChunks())
chunks, coveredChunks := filer.CompactFileChunks(ctx, fs.lookupFileId, nonManifestChunks)
chunks, coveredChunks, err := filer.CompactFileChunks(ctx, fs.lookupFileId, nonManifestChunks)
if err != nil {
return newEntry.GetChunks(), nil, fmt.Errorf("CompactFileChunks: %w", err)
}
garbage = append(garbage, coveredChunks...)
if newEntry.Attributes != nil {
@@ -0,0 +1,47 @@
package weed_server
import (
"context"
"strings"
"testing"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util"
)
// A CreateEntry whose context is cancelled before its chunks are compacted must
// fail the request and store nothing, rather than panic in CompactFileChunks.
func TestCreateEntryCancelledContextFailsRequest(t *testing.T) {
store := newRenameTestStore()
f := newRenameTestFiler(t, store)
fs := &FilerServer{
filer: f,
option: &FilerOption{},
entryLockTable: util.NewLockTable[util.FullPath](),
}
ctx, cancel := context.WithCancel(context.Background())
cancel()
_, err := fs.CreateEntry(ctx, &filer_pb.CreateEntryRequest{
Directory: "/test",
SkipCheckParentDirectory: true,
Entry: &filer_pb.Entry{
Name: "obj",
Attributes: &filer_pb.FuseAttributes{Mtime: 1700000000, FileMode: 0644, Inode: 1},
Chunks: []*filer_pb.FileChunk{
{FileId: "1,01", Offset: 0, Size: 100, ModifiedTsNs: 1},
},
},
})
if err == nil || !strings.Contains(err.Error(), "CompactFileChunks: "+context.Canceled.Error()) {
t.Fatalf("err = %v, want CompactFileChunks to fail with context canceled", err)
}
store.mu.Lock()
defer store.mu.Unlock()
if _, found := store.entries["/test/obj"]; found {
t.Fatal("entry was stored despite the failed request")
}
}