Skip to content

Fix spill buffer ownership on failure - #32164

Merged
XuPeng-SH merged 8 commits into
matrixorigin:4.2-devfrom
iamlinjunhong:fix-32154-spill-buffer-ownership
Nov 9, 2026
Merged

XuPeng-SH merged 8 commits into
matrixorigin:4.2-devfrom
iamlinjunhong:fix-32154-spill-buffer-ownership

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Nov 4, 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:

Spill merge failures could lose track of an output buffer or leave cleanup ownership ambiguous when output moves to accumulated results or an asynchronous pipeline. Keep ownership explicit across buffer acquisition, merge, transfer and failure, and reset the executor on synchronous exit. Errors and panics continue to propagate. Regression tests cover failures and ownership transfers, multi-block content, reset and real sink readback.

Validation on 0fac11533824441409e5e36d276b91c0e4bc1125 (Darwin arm64, Go 1.27.1, CGO), newly executed after rebasing onto official 4.2-dev@7283f12d0eaf919e253dab4ed0d7dc0828c6ff8e:

  • GOWORK=off go build -mod=readonly ./pkg/objectio/ioutil and matching go vet passed with repository CGo include/library paths.
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s ./pkg/objectio/ioutil and the same command with -race passed (78 test roots each).
  • All 17 named ownership/failure/transfer/readback regressions passed focused race execution, then separate exact-name -race -count=N runs (N=13–100, measured 30-second per-test budget capped at 100; 1,601 root repetitions total). This includes the target branch's immediate-release regression.
  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s -run '^TestS3Writer_SortAndSync$' ./pkg/sql/colexec passed. Delivery artifact check passed.

Conflict resolution preserves #32155's byte-bounded staging and borrowed/constant-vector normalization. Failed buffer acquisition immediately releases partial allocations before retiring its ownership claim; its regression now checks immediate mpool baseline restoration. The previous head's required CI passed; CI for this rebased revision will run after push. No new cluster or performance benchmark was run.

The change adds constant-time ownership bookkeeping and defers, without a new per-row scan or I/O. An accumulated spill can retain one existing preallocated output block slightly longer. Reset's wait for accepted pipeline work is supported by source review; the existing test does not establish that Reset has entered its wait, and completion still depends on the downstream sink returning.

@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 →

@XuPeng-SH

XuPeng-SH commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 0563ae73856eda48995be33f96f729f9d108fb47

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: 0563ae73856eda48995be33f96f729f9d108fb47

Assessment: approve

The repair gives each spill buffer one cleanup owner across errors, panics and transfer, reusing the existing pool, staged and pipeline owners. The added bookkeeping is bounded and preserves ordinary content and reuse behavior; no actionable defect remains.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Read the complete two-file delta, all 16 new test roots, linked issue 32154, both discussion items, and merge/pool/pipeline/consumer cleanup paths. Ownership analysis is retained in ownership-review.md.

  • Static source, patch, discussion and native-provenance audit passed: checks/1793789254839977737-2.json; scope-audit.log. Isolation preflight, pinned CPU native build and loader inspection passed; native-inputs.json/native-outputs.json retain provenance.

  • Frozen exact-head CI reports 12 successful, 13 skipped and 2 neutral checks, including UT and coverage success. The PR body reports Darwin normal/race owning-package and repeated focused validation; those reports are reused within their stated scope.

  • Local focused execution first stopped at missing native prerequisites. After recovery, module resolution timed out at 300s with zero named test events: checks/1793789347992131810-2.json; focused-native-tests.log. This is not counted as a test pass or product failure.

Limitations:

  • No local Go behavioral or race test completed; raw author logs and adaptive repetition details were not supplied.

  • The Reset-generation test does not deterministically prove entry into the wait. The unchanged pending.Wait supplies that source proof; downstream completion remains required, as acknowledged in the PR.

@XuPeng-SH

XuPeng-SH commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 0fac11533824441409e5e36d276b91c0e4bc1125

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: 0fac11533824441409e5e36d276b91c0e4bc1125

Assessment: approve

Spill buffers retain one cleanup owner through acquisition failure, merge errors/panics and pipeline handoff. The fix reuses existing ownership mechanisms with bounded bookkeeping. No actionable correctness or design findings remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed the complete delta, all four discussion entries, linked issue #32154, 16 new regression roots and the existing immediate-release regression; traced affected owners and consumers.

  • Local source/evidence audit passed: exact head and delta, clean source, diff whitespace, gofmt, test inventory and discussion coverage. Receipt: checks/1793810910861331049-2.json; retained log/report: source-audit.log and source-audit.json.

  • Reused supplied exact-head CI evidence: build, UT, SCA/coverage and multi-CN BVT succeeded; 12 success, 13 skipped and 2 neutral.

  • Reused current-head author reports of build/vet, normal/race package tests, 17 focused regressions, 1601 adaptive race repetitions and S3 writer integration. These are attributed reports, not local executions.

Limitations:

  • No local Go runtime or race tests were executed; raw author logs and native-input provenance were not supplied.

  • The Reset test does not deterministically prove entry into Wait. Generation safety follows the unchanged drain-before-reuse path; accepted workers still require downstream completion.

@XuPeng-SH
XuPeng-SH merged commit e4f70a7 into matrixorigin:4.2-dev Nov 9, 2026
XuPeng-SH added a commit that referenced this pull request Nov 13, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to #32146.

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

Backport the large-variable-length write memory fixes and their
lifecycle dependencies to `v4.2.8-hotfix`. A 196,092-row fixture with
very large JSON/text values completes its batched UPDATE on 4.2.8 but
OOM-kills a 20-GiB CN during the subsequent VARCHAR-to-INT COPY ALTER.
The backports bound CN spill runs and pooled writer retention while
preserving buffer/object ownership through completion, cancellation, and
failure.

Cherry-picked with source provenance, in order: #32081, #32155, #32332,
#32164, #32398, #32454, and #32065. The target branch's existing #32704
is retained. There are no manual production-code changes to the seven
backports.

Validation on head `cc1d6c51a156e232182030b093bbf9bfc1ae95c1`:

- Fresh native build succeeds with actual-head version/commit metadata.
Formatting and `git diff --check` pass. All seven commits have identical
added/removed lines and paths to their source commits; only #32155 has
documentation-only unchanged-context differences.
- Actual-head full-data run PASS: 196,092 rows, 147,941 converted rows;
PK/row count, payload byte lengths and CRC sums, final statuses, and INT
type verified. All roles report `OOMKilled=false`.
- CN limit and total memory+swap are both 20 GiB, 6 CPUs, GOMEMLIMIT 1
GiB, cache 2 GiB. Sampled CN RSS peak: **12.4115 GiB** (2-second
sampling). Sampled cgroup usage peak: 19.7955 GiB; kernel cgroup
high-water reached 20 GiB, with zero failcnt/OOM. RSS is not total
container memory, so this does not imply 7.6 GiB of container headroom.
- Driver start through final verification: **431.90 s (7m12s)**,
including token UPDATE **221.59 s**, token COPY ALTER **200.84 s**, and
remaining validation/setup. Service startup and cold-backup restore are
excluded.
- Native-toolchain scoped regressions pass: nine owning packages (2,302
tests/subtests); compile import/cancellation selector (153); focused
race checks across mpool, rscthrottler, objectio and ioutil (93). Runs
use `-count=1`, the repository CGo test wrapper, and default vet checks.
No failures; task services are stopped. Full-repository CI/review is not
part of this local validation, and further GitHub results are not
awaited.

The workload measures the MOI offset212 token-table migration, with
placeholder companion tables, rather than all MOI deployment phases.
Logical restore uses a shared DISK backend and changes the original
physical object layout; customer data and raw logs are not included in
this PR. Single-run timings are not a statistical performance benchmark.


Revision `b6b9f3ba40d7bb9e598b2a8846b7ed166b4a48b7` (test-only
follow-up):

- Carries #32439's unordered two-observation reset assertion and
#28467's 512-MiB RLIMIT target; closes the actual fixture-owned
increment service; adapts first-replay setup to this release's embed API
and TCP SQL transport. Production changes in the seven backports remain
identical to their sources.
- New local validation (Darwin/arm64, Go 1.27.1, CGo wrapper,
`-count=1`): owning production packages build; all four changed test
packages vet; `objectio/ioutil` full coverage and race pass; `mpool`
coverage passes; `sql/compile` full normal and race pass with
`TMPDIR=/private/tmp`; first-replay
startup/disconnect/reconnect/prepared SQL passes normal and race.
Spill-reset and fixture-ownership tests each pass `-race -count=100`.
Formatting, diff whitespace, and delivery artifact checks pass.
- Run 43449877707 attempt 1 failed SCA job 131969091882 (`make
static-check-analysis`) on missing `embed.WithDataPath`; coverage job
131969165708 reports that build error, RLIMIT runtime allocation
failure, and the fixture closure assertion. These backported test
defects are addressed here; the old run is not rerun because the push
triggers fresh CI. Pinned molint rebuilt for the local Go version exits
zero but emits inherited analyzer diagnostics; this is not a
zero-diagnostic SCA claim.
- Local Parquet fanout failures also reproduce in an unmodified archive
of target base `b572b5cd95a25d404cd0f0df32629b39c6fff120`; full PR
compile normal/race pass with a short temporary root. No Parquet
code/test is changed. Linux-only RLIMIT execution is reused from
#28467's upstream coverage/race evidence; not executed on this Darwin
host. Original migration and other upstream validation above retain
their stated revisions/configurations; the customer-data migration was
not repeated for these test changes. New CI is not awaited. Raw local
logs remain outside the source tree.

---------

Co-authored-by: aptend <[email protected]>
Co-authored-by: XuPeng-SH <[email protected]>
Co-authored-by: GreatRiver <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: 和光同尘 <[email protected]>
Co-authored-by: jiangxinmeng1 <[email protected]>
aptend pushed a commit to aptend/matrixone that referenced this pull request Nov 22, 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:

- matrixorigin#32154

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

Spill merge failures could lose track of an output buffer or leave
cleanup ownership ambiguous when output moves to accumulated results or
an asynchronous pipeline. Keep ownership explicit across buffer
acquisition, merge, transfer and failure, and reset the executor on
synchronous exit. Errors and panics continue to propagate. Regression
tests cover failures and ownership transfers, multi-block content, reset
and real sink readback.

Validation on `0fac11533824441409e5e36d276b91c0e4bc1125` (Darwin arm64,
Go 1.27.1, CGO), newly executed after rebasing onto official
`4.2-dev@7283f12`:

- `GOWORK=off go build -mod=readonly ./pkg/objectio/ioutil` and matching
`go vet` passed with repository CGo include/library paths.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s
./pkg/objectio/ioutil` and the same command with `-race` passed (78 test
roots each).
- All 17 named ownership/failure/transfer/readback regressions passed
focused race execution, then separate exact-name `-race -count=N` runs
(N=13–100, measured 30-second per-test budget capped at 100; 1,601 root
repetitions total). This includes the target branch's immediate-release
regression.
- `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=240s -run
'^TestS3Writer_SortAndSync$' ./pkg/sql/colexec` passed. Delivery
artifact check passed.

Conflict resolution preserves matrixorigin#32155's byte-bounded staging and
borrowed/constant-vector normalization. Failed buffer acquisition
immediately releases partial allocations before retiring its ownership
claim; its regression now checks immediate mpool baseline restoration.
The previous head's required CI passed; CI for this rebased revision
will run after push. No new cluster or performance benchmark was run.

The change adds constant-time ownership bookkeeping and defers, without
a new per-row scan or I/O. An accumulated spill can retain one existing
preallocated output block slightly longer. Reset's wait for accepted
pipeline work is supported by source review; the existing test does not
establish that Reset has entered its wait, and completion still depends
on the downstream sink returning.

---------

Co-authored-by: XuPeng-SH <[email protected]>
(cherry picked from commit e4f70a7)

This branch was successfully deployed

No deployments
ci — 464a41d8 Deployed Nov 9, 2026 by XuPeng-SH
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 size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants