Skip to content

[4.2-dev] Bound pooled WriteArena serialization buffer retention - #32454

Merged
XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
jiangxinmeng1:codex/29384-serialbuf-42dev
Nov 10, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:4.2-devfrom
jiangxinmeng1:codex/29384-serialbuf-42dev

Conversation

@jiangxinmeng1

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #29384 (4.2-dev backport; main fix #29432)

What this PR does / why we need it:

A Merge writer can grow WriteArena.serialBuf on the Go heap and leave that large capacity parked in the arena pool after the task finishes. Limit pooled serialization capacity to 16 MiB per arena before publication, retain large scratch only while an active write cycle needs it, and clear it on FreeBuffers. Add a pooled-capacity gauge with accounting ordered before lock-free publication. No wire-format changes or off-heap arena-size tuning.

Regression coverage includes a real object writer and two sequential MergeObjects tasks in one TAE engine. Before the fix the writer retained 16,785,408 bytes and the Merge test observed 19,079,168 pooled bytes; both tests pass with this patch. Build and vet passed for objectio, metric, TAE jobs and DB consumers. Full objectio/metric normal and race suites passed. Focused race stress passed for the new tests (49/68/100/13 runs).

TAE package race passed in 134 s with only Test_RWDB4 excluded. The unfiltered package timed out at 600 s in Test_RWDB4; that test also timed out at 120 s both on this branch and on a clean 4.2-dev baseline at 9dd4d33. This baseline timeout is an existing validation gap, not a passing full-suite claim.

The cap trades occasional reallocation for bounded parked Go-heap retention. The gauge may briefly overcount an arena between accounting and CAS publication, but settles after the transfer.

@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 10, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 67d7a69d33efbdd0602e6a31c04dfeff936ae629

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: 67d7a69d33efbdd0602e6a31c04dfeff936ae629

Assessment: approve

The retention fix extends the existing arena lifecycle and pool owners without a new cache or worker. Tracking the uncompressed column peak is appropriate because compressed allocation demand cannot identify oversized serialization scratch. Trimming and gauge accounting precede lock-free publication, and Get/drain cleanup preserves ownership. No actionable defect remains in the six-file scope.

Model: gpt-6.1-sol / max

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

Validation:

  • Reviewed the complete delta, linked issue #29384, both discussion entries, serialization/compression consumers and merge/flush/CN/sinker release paths; ownership and bounded-cost conclusions are retained in review-plan.md.

  • Source/threshold/ordering-model audit passed: checks/1794294733117136176-3.json and arena-review-audit.log/json. Verified the frozen source, unchanged synchronous compression copy, strict retention boundaries and 1,680 legal scalar transfer orders. This is not a Go race or engine test.

  • Whitespace and gofmt checks passed with empty logs: checks/1794294708248007313-3.json (diff-check.log) and checks/1794294708253782948-3.json (gofmt-check.log). All check commands/source/exits/logs are reconciled in validation-ledger.json.

  • Reused frozen exact-head successful shared build, x86 UT, arm64 SCA, coverage, PROXY and pessimistic multi-CN BVT evidence. Skipped/neutral contexts are not passes.

  • Author reports full objectio/metric normal and race suites, build/vet of direct and dependent consumers, four focused race repetitions (49/68/100/13) and real writer/two-task engine regressions. These reports support the source review but were not rerun locally.

Limitations:

  • No fresh local Go, writer, engine or race execution; matching native prerequisites are absent from the read-only checkout. Raw author and CI logs were not supplied.

  • The author reports an unfiltered TAE race timeout in Test_RWDB4, a successful filtered run, and a clean-baseline timeout control. The full TAE race suite is not counted as passed, and baseline attribution was not independently reproduced.

@XuPeng-SH
XuPeng-SH merged commit c8264f1 into matrixorigin:4.2-dev Nov 10, 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
…rixorigin#32454)

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

issue matrixorigin#29384 (4.2-dev backport; main fix matrixorigin#29432)

A Merge writer can grow WriteArena.serialBuf on the Go heap and leave
that large capacity parked in the arena pool after the task finishes.
Limit pooled serialization capacity to 16 MiB per arena before
publication, retain large scratch only while an active write cycle needs
it, and clear it on FreeBuffers. Add a pooled-capacity gauge with
accounting ordered before lock-free publication. No wire-format changes
or off-heap arena-size tuning.

Regression coverage includes a real object writer and two sequential
MergeObjects tasks in one TAE engine. Before the fix the writer retained
16,785,408 bytes and the Merge test observed 19,079,168 pooled bytes;
both tests pass with this patch. Build and vet passed for objectio,
metric, TAE jobs and DB consumers. Full objectio/metric normal and race
suites passed. Focused race stress passed for the new tests
(49/68/100/13 runs).

TAE package race passed in 134 s with only Test_RWDB4 excluded. The
unfiltered package timed out at 600 s in Test_RWDB4; that test also
timed out at 120 s both on this branch and on a clean 4.2-dev baseline
at 9dd4d33. This baseline timeout is an existing validation gap, not
a passing full-suite claim.

The cap trades occasional reallocation for bounded parked Go-heap
retention. The gauge may briefly overcount an arena between accounting
and CAS publication, but settles after the transfer.

(cherry picked from commit c8264f1)

This branch was previously deployed

1 inactive deployment
ci — 67d7a69d Deployed Nov 10, 2026 by jiangxinmeng1
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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants