Skip to content

fix(objectio): release partial read cache data on error - #24311

Merged
mergify[bot] merged 7 commits into
matrixorigin:3.0-devfrom
LeftHandCold:fix-objectio-partial-read-release
May 9, 2026
Merged

mergify[bot] merged 7 commits into
matrixorigin:3.0-devfrom
LeftHandCold:fix-objectio-partial-read-release

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented May 8, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24310

What this PR does / why we need it:

Fixes ObjectIO partial-read error paths that can drop IOEntry.CachedData without releasing it. When a FileService read fills some cache entries and then returns an error, for example after a LIMIT query cancels parallel table-scan workers, the read helper previously returned without releasing the partially-filled read results. Under cache eviction this can surface as a checked malloc missing free panic from fileservice.Bytes allocated through DiskCache.Read -> objectio.constructorFactory.

This PR:

  • Adds IOVector.ReleaseReadResultOnError() to release cached data and raw read buffers only for completed entries, avoiding double-deallocation of an entry whose ReadFromOSFile already unwound its own failed raw buffer.
  • Uses that cleanup in ReadOneBlockWithMeta, ReadExtent, ReadAllBlocksWithMeta, and ReadOneBlockAllColumns when fs.Read or post-read processing returns an error.
  • Releases allocated decompression cache data if LZ4 decompression fails before ownership is returned.
  • Adds unit coverage for partial-read cleanup, skipped failed-entry raw-buffer release, and decompression-error cleanup.

Validation

PROJECTROOT=/Users/shenjiangwei/Work/code/view/matrixone
export CGO_CFLAGS="-I$PROJECTROOT/cgo -I$PROJECTROOT/thirdparties/install/include"
export CGO_LDFLAGS="-Wl,-w,-rpath,$PROJECTROOT/thirdparties/install/lib -L$PROJECTROOT/thirdparties/install/lib -L$PROJECTROOT/cgo -lmo"
go test -mod=mod ./pkg/fileservice -run TestIOVectorReleaseReadResultOnErrorSkipsUndoneReleaseData -count=1
go test -mod=mod ./pkg/objectio -count=1

Release IOVector cache data when objectio read helpers return after a partial FileService read error. Also release decompression cache data if LZ4 decompression fails before ownership is returned.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings May 8, 2026 06:27
@LeftHandCold
LeftHandCold requested a review from XuPeng-SH as a code owner May 8, 2026 06:27
@qodo-code-review

Copy link
Copy Markdown
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes pkg/objectio read-helper error paths to ensure partially filled fileservice.IOVector cache data is released when FileService.Read returns an error (e.g., cancellation during parallel scans), and adds unit tests to cover several partial-read cleanup scenarios.

Changes:

  • Release partially filled IOVector entries on fs.Read error in ReadExtent, ReadOneBlockWithMeta, ReadAllBlocksWithMeta, and ReadOneBlockAllColumns.
  • Release allocated decompression cache data when LZ4 decompression fails inside constructorFactory.
  • Add unit tests that simulate “partial cache fill + read error” and assert the cache data is released.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
pkg/objectio/funcs.go Adds release-on-error logic to multiple ObjectIO read helpers to prevent leaking partially filled cached data.
pkg/objectio/constructors.go Ensures decompression-allocated cache data is released on LZ4 decompression failure.
pkg/objectio/funcs_test.go Adds unit tests covering partial-read cleanup behavior for several helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/objectio/funcs.go Resolved
Comment thread pkg/objectio/funcs.go Resolved
Comment thread pkg/objectio/constructors.go Resolved
Comment thread pkg/objectio/funcs.go Resolved
Comment thread pkg/objectio/funcs.go Resolved
Add coverage for ReadAllBlocksWithMeta partial read cleanup and constructorFactory decompression failure cleanup.

Co-authored-by: Copilot <[email protected]>
@LeftHandCold

Copy link
Copy Markdown
Collaborator Author

Reviewed the latest PR against issue #24310. The partial-read leak path is addressed: the objectio helpers now release filled CachedData when fs.Read or follow-up processing returns an error, and constructorFactory releases the allocated decompression cache buffer if LZ4 decode fails before ownership is returned. I specifically checked the double-free concern: ReleaseReadResultOnError nils CachedData after releasing it, and only calls releaseData for entries marked done, so failed ReadFromOSFile entries whose prepareData defer already unwound their raw buffer are skipped. The issue did not show up before because successful reads transfer ownership to normal callers, but LIMIT/parallel scan cancellation can make FileService.Read return an error after some entries were already filled, leaving those cache references unreachable until eviction exposes the missing free. I do not see blocking regression risk in this change.

Release schema-evolution generated cache data when ReadOneBlockWithMeta returns an error, and make error-returned IOVectors inert after cleanup.

Co-authored-by: Copilot <[email protected]>
Clear done/fromCache when ReleaseReadResultOnError discards partially filled read results so entries are left in a consistent retry-safe state.

Co-authored-by: Copilot <[email protected]>
@mergify

mergify Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-05-09 04:18 UTC · Rule: release-3.0
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-05-09 05:12 UTC · at c6d0ade5149b2a6d9f19743716a14c6e7c37f0d3 · squash

This pull request spent 53 minutes 34 seconds in the queue, including 53 minutes 19 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI (3.0) / Coverage
    • check-neutral = Matrixone Utils CI (3.0) / Coverage
    • check-skipped = Matrixone Utils CI (3.0) / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI (3.0) / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI (3.0) / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI (3.0) / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI (3.0) / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI (3.0) / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI (3.0) / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI (3.0) / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI (3.0) / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI (3.0) / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI (3.0) / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI (3.0) / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI (3.0) / Compatibility Test With Target on Linux/x64(LAUNCH)

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants