Skip to content

Return fileservice read buffer allocation errors - #33129

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/33095-main
Nov 24, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/loom/33095-main

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

What this PR does / why we need it:

Fileservice panics when it needs a new read buffer and the allocator returns ENOMEM. Return the allocator error to the caller before reading or marking the entry complete. A read with sufficient existing capacity reuses that buffer without allocating.

If a LocalFS read fails after allocating a new buffer, its rollback clears the owning entry and releases the buffer once. If the read reuses an existing buffer, LocalFS publishes the resized slice only after both the read and cache conversion succeed. Disk cache reads retain their existing fallback on errors.

Validation

  • Main baseline e17d5541537d30252009a9a2d4c70ab5480d3bc3 (macOS arm64, Go 1.27.1). The issue's one-byte reproducer panicked after one allocation attempt when a buffer was needed. The existing-buffer case read the byte with zero allocations. The issue reports the same baseline behavior on 4.2-dev.
  • Main candidate be16d27be8fb21cd716620c4c7b86f1bc8e1f238 (macOS arm64, Go 1.27.1 with CGo). make -j8 build, the issue's reproducer, focused fileservice tests, QA probes, and changed-code lint passed.
  • 4.2-dev candidate fe121f6df07f1ac60826c5df1651c7ecbe108d96 (macOS arm64, Go 1.26.4 with CGo). Its branch-specific make -j8 build and the same reproducer, focused fileservice tests, QA probes, and changed-code lint passed.

Both candidates returned an error matching syscall.ENOMEM after one allocation attempt, with the file offset unchanged and the entry incomplete. Both read the correct byte with zero allocations when capacity was sufficient. The QA probes also covered LocalFS rollback, short reads, conversion failures, and disk cache fallback. These are local results. PR CI runs separately.

The current main PR head (416f5765909c5a0eeee117eb480d11019608b98c, Go 1.27.1) and the current 4.2-dev PR head (3cb144de818ec1ef25b9fd1b0de5859ace52eba8, Go 1.26.4) each passed make -j8 build, mo-service -version, the issue reproducer, the focused fileservice tests, and the QA probes on macOS arm64 with CGo.

Performance and deployment scope

The read path adds a capacity branch and a publication check in LocalFS. The capacity-reuse tests confirmed zero allocations. The patch is expected to prevent the fileservice panic observed during the reported Linux CN checkpoint read when the allocator returns ENOMEM. The original CN workload, the mapping growth that reached the limit, and container restart behavior remain unverified by these tests.

Related PR

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Nov 24, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Nov 24, 2026
@mergify

mergify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@XuPeng-SH

XuPeng-SH commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 416f5765909c5a0eeee117eb480d11019608b98c

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mo-bot review · mo-bot-local · review

Commit: 416f5765909c5a0eeee117eb480d11019608b98c

Assessment: approve

The patch returns ENOMEM before advancing the reader or completing the entry. LocalFS cleanup now clears the entry that owns a newly allocated buffer, and it publishes the resized caller buffer only after the read and conversion succeed. Disk cache read errors still allow fallback to the source.

Model: gpt-6.2-sol / xhigh

Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3

Validation:

  • Verified the clean frozen checkout, merge base, patch and whitespace, pinned policy, native inputs, and isolation preflight. Receipts and logs are matched in validation-reconciliation.json.

  • Ten focused Linux fileservice tests passed, including the ENOMEM and zero-allocation controls, LocalFS cleanup after a later entry fails, short reads, cache conversion errors, and cache read controls. See fileservice-check.jsonl and checks/1795497728038585101-2.json.

  • The frozen head records successful Ubuntu x86 unit tests, arm64 static analysis, and two multi-CN BVT jobs. The author reports same-head macOS arm64 build and QA coverage. All three discussion notices are accounted for.

Limitations:

  • The focused tests exercise the affected reader, filesystem, and cache boundaries. The original Linux CN workload, mapping growth, and restart behavior were outside this validation.

@mergify mergify Bot added the queued label Nov 24, 2026
@mergify

mergify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request dequeued

1 h 18 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Tue 24 Nov, 05:23 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 06:41 · ffe722b

Reason

Pull request #33129 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

To get back in the queue

  • Push a change if one is needed: the pull request is queued again once its queue conditions match.
  • If no change is needed, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH
XuPeng-SH merged commit 8b1e884 into matrixorigin:main Nov 24, 2026
@mergify mergify Bot added dequeued and removed queued labels Nov 24, 2026
mergify Bot pushed a commit that referenced this pull request Nov 24, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

- #33095

## What this PR does / why we need it:

Fileservice panics when it needs a new read buffer and the allocator returns `ENOMEM`. Return the allocator error to the caller before reading or marking the entry complete. A read with sufficient existing capacity reuses that buffer without allocating.

If a LocalFS read fails after allocating a new buffer, its rollback clears the owning entry and releases the buffer once. If the read reuses an existing buffer, LocalFS publishes the resized slice only after both the read and cache conversion succeed. Disk cache reads propagate ENOMEM to the caller before object-store fallback. Ordinary cache misses and read errors still fall back. When a later entry fails after a partial disk-cache hit, error cleanup clears the released buffer and its published reader so the same IOVector can be retried safely.

### Validation

- Main baseline `e17d5541537d30252009a9a2d4c70ab5480d3bc3` (macOS arm64, Go 1.27.1). The issue's one-byte reproducer panicked after one allocation attempt when a buffer was needed. The existing-buffer case read the byte with zero allocations. The issue reports the same baseline behavior on `4.2-dev`.
- Main candidate `be16d27be8fb21cd716620c4c7b86f1bc8e1f238` (macOS arm64, Go 1.27.1 with CGo). `make -j8 build`, the issue's reproducer, focused fileservice tests, QA probes, and changed-code lint passed.
- `4.2-dev` candidate `fe121f6df07f1ac60826c5df1651c7ecbe108d96` (macOS arm64, Go 1.26.4 with CGo). Its branch-specific `make -j8 build` and the same reproducer, focused fileservice tests, QA probes, and changed-code lint passed.

Both candidates returned an error matching `syscall.ENOMEM` after one allocation attempt, with the file offset unchanged and the entry incomplete. Both read the correct byte with zero allocations when capacity was sufficient. The QA probes also covered LocalFS rollback, short reads, conversion failures, and disk cache fallback. These are local results. PR CI runs separately.

**Disk-cache follow-up at `8b85a3a815c3194c10697c96fe2613bdc68a62d1` (Darwin/arm64, Go 1.26.4, CGo)**

- `TestS3FSReadDiskCacheAllocationFailure` reproduced the fallback allocation panic on `3cb144de818ec1ef25b9fd1b0de5859ace52eba8`. The repaired read returns ENOMEM without calling object storage or the cache-data allocator. The miss and short-read controls fetch the correct data, and the short-read buffer is released once.
- Focused fileservice and ObjectIO cleanup tests passed with `-race -short -tags matrixone_test`. The fileservice package passed in the same mode with `TestMinioSDK` excluded because its external endpoint denied access in the earlier local run. Fileservice vet and incremental lint passed.
- [CI on the preceding head](https://github.com/matrixorigin/matrixone/actions/runs/45322973397/attempts/2) passed. The injected test covers the fileservice path. The original Linux mapping exhaustion and CN restart behavior remain unverified.

**Partial-hit cleanup at `762408a73d7d6d9975036fb8bdd5465d875ad90a` (Darwin/arm64, Go 1.26.4, CGo)**

- The new `TestS3FSReadDiskCacheAllocationFailure` partial-hit case reproduced the stale owned buffer on the reviewed head. After the fix, cleanup clears the buffer and reader, and retrying the same vector reads both entries with fresh owned storage. The caller-buffer control retains and reuses its supplied capacity.
- Focused fileservice and ObjectIO cleanup tests passed with `-race -short -tags matrixone_test`. The fileservice package passed in the same mode with `TestMinioSDK` excluded because its external endpoint denied access in an earlier local run. Fileservice vet and incremental lint passed.
- [CI on the reviewed head](https://github.com/matrixorigin/matrixone/actions/runs/45390360095/attempts/2) passed. The local tests inject allocation failures. They do not reproduce the original Linux mapping exhaustion.

### Performance and deployment scope

The read path adds a capacity branch and a publication check in LocalFS. The capacity-reuse tests confirmed zero allocations. The patch is expected to prevent the fileservice panic observed during the reported Linux CN checkpoint read when the allocator returns `ENOMEM`. The original CN workload, the mapping growth that reached the limit, and container restart behavior remain unverified by these tests.

### Related PR

- Main implementation [#33129](#33129).


Approved-by: fengttt <[email protected]>
Approved-by: XuPeng-SH <[email protected]>

This branch was successfully deployed

No deployments
ci — ffe722bb Deployed Nov 24, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants