Repository navigation
Description
Bug Report
A CN process can crash with panic: missing free from the checked malloc allocator during cached object reads. This is not a cgroup OOM: in the investigated logs the CN RSS stayed around 31-37GiB with a 74GiB cgroup limit, while the final crash was a checked allocator panic.
Evidence
The crash stack points to cache data allocated while reading object columns from the disk cache:
panic: missing free: address ..., size 196646, allocated at github.com/matrixorigin/matrixone/pkg/common/malloc.(*CheckedAllocator[...]).Allocate.func1
...
github.com/matrixorigin/matrixone/pkg/fileservice.(*bytesAllocator).allocateCacheData
github.com/matrixorigin/matrixone/pkg/fileservice.(*S3FS).AllocateCacheDataWithHint
github.com/matrixorigin/matrixone/pkg/objectio.constructorFactory.func1
github.com/matrixorigin/matrixone/pkg/fileservice.(*IOEntry).setCachedData
github.com/matrixorigin/matrixone/pkg/fileservice.(*IOEntry).ReadFromOSFile
github.com/matrixorigin/matrixone/pkg/fileservice.(*DiskCache).Read
github.com/matrixorigin/matrixone/pkg/objectio.ReadOneBlockWithMeta
github.com/matrixorigin/matrixone/pkg/objectio.ReadOneBlock
github.com/matrixorigin/matrixone/pkg/objectio/ioutil.LoadColumnsData
github.com/matrixorigin/matrixone/pkg/vm/engine/tae/blockio.readBlockData
github.com/matrixorigin/matrixone/pkg/sql/colexec/table_scan.(*TableScan).Call
github.com/matrixorigin/matrixone/pkg/sql/colexec/limit.(*Limit).Call
Goroutine leak-check profiles taken shortly before the crash showed many concurrent table_scan -> BlockDataRead -> ReadOneBlockWithMeta -> S3FS.Read -> DiskCache.Read -> IOEntry.setCachedData goroutines. Some goroutines were also evicting memory-cache entries through S3FS.AllocateCacheDataWithHint -> EnsureNBytes -> Bytes.Release, which is the path that exposes an unreleased caller reference when cache pressure evicts the retained cache copy.
Root cause
ObjectIO read helpers transferred ownership of IOEntry.CachedData to their callers only on successful reads, but several error paths did not release partially-filled IOVectors:
ReadOneBlockWithMetareturned immediately whenfs.Readfailed, even iffs.Readhad already filled one or moreIOEntry.CachedDatavalues.ReadExtent,ReadAllBlocksWithMeta, andReadOneBlockAllColumnshad the same partial-read cleanup gap.constructorFactoryallocated decompression cache data before LZ4 decompression; if decompression failed, that allocatedfscache.Datawas returned through an error path withoutRelease.
In a LIMIT / parallel table scan, one worker can satisfy the limit and cancel other readers. A canceled FileService.Read may have already filled some cache entries before returning an error. Dropping those entries without IOVector.Release() leaves Bytes with a non-zero internal ref count but no reachable owner. Later memory-cache eviction makes the object collectible, and CheckedAllocator finalizer panics with missing free.
Expected behavior
Any ObjectIO helper that returns an error after a partially successful FileService read must release all filled cache data before returning the error.
Activity