Skip to content

[4.2-dev] fix(disttae): account workspace copies against CN memory budget - #32536

Draft
VioletQwQ-0 wants to merge 16 commits into
matrixorigin:4.2-devfrom
VioletQwQ-0:codex/4.2-dev-txn-workspace-memory
Draft

VioletQwQ-0 wants to merge 16 commits into
matrixorigin:4.2-devfrom
VioletQwQ-0:codex/4.2-dev-txn-workspace-memory

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Nov 11, 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:

Related to #32008. Release-specific adaptation of #32458; this does not establish closure of the historical OOM.

What this PR does / why we need it:

On 4.2, transaction workspace copies can outlive their statement without participating in the CN allocation budget. This change places those copies on independent transaction generations of the existing HashBuild CN ledger, preserving its recovery-capacity semantics and physical Free as the refund owner. Dynamic headroom uses retained pre-sample backing so pending allocations and freed/reallocated backing cannot reuse an old sample's credit.

The release also needs publication prerequisites: stage merge/dump/compaction results before replacement, preserve statement boundaries on failure, adopt regenerated rowids rather than duplicating them, and retain persisted-but-unrecorded objects through bounded shared-claim cleanup. Sinker admission precedes persistence, and GC producers are fenced against Engine close. This selects the required local ownership mechanisms without importing the complete #29646/#30988 changes or changing wire/storage formats or user settings.

Design and independent review: docs/design/txn-workspace-memory-4.2.md (design-first revision 2f84010, followed by separately recorded implementation review).

Validation:

  • PASS: allocator/system/process/util UT and focused race; full disttae UT (420 top-level tests, 872 nodes), focused workspace race, full Sinker/colexec and affected INSERT/DELETE/multi-update UT.
  • PASS: incremental vet/lint and diff checks.
  • PASS: current production content (bef35e7) rebuilt and all 211 local SQL BVT statements passed; no failed, skipped or abnormal statements. Includes 92 workspace statements with six expected capacity refusals, retained prior writes, later writes/commit and cross-session visibility checks. The binary embeds b39 version metadata because the commit landed during the source-frozen build; before/after content-tree hashes and an empty final diff reconcile it to the current production content. The release fixture uses two legal 32 KiB strings because its REPEAT returns NULL above 65535 bytes.
  • PASS: unchanged cn_spill_byte_bound, workspace_filter and update_workspace SQL BVT; every selected case completed with no failed, skipped or abnormal statements.
  • Exact-head CI: queued/running at bef35e7; not yet qualified. Initial b39 CI found three engine integration failures and Linux SCA findings. The anchor/statement-prefix publication fix, stronger GC lifecycle fixture and SCA fixes are included in the current head. The three targeted engine regressions plus prefix/rollback boundary regression passed before the final allocation-only preallocation delta; independent review approved the final delta.
  • A later full local engine package and focused repeat were refused by the real physical-headroom gate (cap=0) under Mac host pressure. These are retained as failed attempts / NOT_ADMITTED qualification, with no accounting bypass; new exact-head Linux CI remains required.
  • Fresh Linux 4 CPU/16 GiB cgroup QA: NOT_RUN / BLOCKED_ENVIRONMENT. Normal baseline build run 42997336254 failed before Go compilation in thirdparties/Makefile:202 (ONNX download curl28), including one reviewed same-run attempt2 retry after the controller independently verified the exact asset size/SHA. Candidate build was not dispatched because the baseline-success gate remains closed. No Linux runtime was started or environment reservation taken.
  • Serial/concurrent/mixed transaction performance, three paired runs (30s warmup, >=120s measurement), TPS decrease and p95 increase each <=5%: NOT_RUN.

Cross-statement merges remain separated by statement region to preserve rollback ownership. The associated batch/commit cost must pass the performance gate. Local copy/merge tests or microbenchmarks do not substitute for it. Keep this PR draft until the remaining acceptance gates are resolved.

Target refresh: 4.2-dev advanced from 42aac81 to d471786 (#32496) during validation. Independently reviewed the complete increment: only GetTableDef property filtering overlaps a source file, with no hunk or ownership/admission dependency. No forced sync was needed. The frozen 42aac81 vs bef35e7 comparison isolates this backport; merge-combination qualification remains separate.

No original experiment namespace/PVC/receiver changes, formal rerun or production deployment are included.

Keep real Linux allocation refusal in the resize ownership test while leaving room for runtime mappings and avoiding high-watermark logging under the limit. Preallocate bounded workspace slices and defer closing EXPLAIN rows on all exits.

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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants