Skip to content

objectio: partial read errors can leak cache data and trigger missing free panic #24310

Closed

Description

@LeftHandCold

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:

  • ReadOneBlockWithMeta returned immediately when fs.Read failed, even if fs.Read had already filled one or more IOEntry.CachedData values.
  • ReadExtent, ReadAllBlocksWithMeta, and ReadOneBlockAllColumns had the same partial-read cleanup gap.
  • constructorFactory allocated decompression cache data before LZ4 decompression; if decompression failed, that allocated fscache.Data was returned through an error path without Release.

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

  1. self-assigned this
    on May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions