Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
Observed on the deployed 4.2 build v4.2.6-71498157cc-2026-10-20. The CN merge paths were also inspected on main and 4.2-dev at the commits below.
Commit ID
- Observed build:
71498157cc21f833b8e717f45d50d1f926be3134. - Code inspection:
main@b27f3869e6f2552311fbbdda2f62b0ca31ec3a67and4.2-dev@88e5fb541768ff65e2220f520e7edd9647034635.
Other Environment Information
A CN executing a large UPDATE on a table with variable-length columns; a sorted CN S3 spill writes the updated data.
Actual Behavior
On the observed build, repeated executions failed during a sorted streaming spill. The captured stack goes through:
MultiUpdate.update_s3 -> s3WriterDelegate.append -> CNS3Writer.Write
-> Sinker.Write -> trySpillMergeSortStreaming -> BlockWriter.WriteBatch
-> objectWriterV1.addBlock -> WriteWithCompress -> WriteArena.CompressBuf
The stack shows a serialized column input of 1,107,036,297 bytes (about 1.031 GiB) and an LZ4 scratch bound of 1,111,377,631 bytes (about 1.035 GiB). The old CompressBuf rounded that bound up to 2,147,483,648 bytes, exceeding the mpool single-allocation limit, and the query failed with mpool memory allocation exceed limit with requested size 2147483648.
The CN subsequently reached its container memory limit and was OOM-killed. These events are correlated; the available evidence does not establish that this particular query alone caused the OOM, identify the large column, or determine whether the 1.031 GiB vector came from one row or multiple rows.
The rounding defect is already tracked by #32051 and fixed in main by #32052 and in 4.2-dev by #32081; the deployed build predates both fixes. Those changes also add byte-aware output to the TN merge/reshape paths. This issue concerns the separate CN sorted spill path and its memory behavior after those fixes, not a request to duplicate the rounding fix.
In the inspected main and 4.2-dev versions, Sinker.trySpillMergeSortStreaming calls mergeutil.MergeSortBatches; its output is flushed at BlockMaxRows (8192 rows) or at the end, rather than at a byte threshold. The current main version also has a disjoint-range fast path with a row-count boundary. A row limit does not bound the size of variable-length columns. The staging threshold is checked after adding a batch and is not itself a bound on the size of an individual output block.
Main also contains an optional chunked-column writer policy; its effective rollout and coverage for this CN path must be checked during validation. Source inspection identifies the remaining large-block risk; it does not establish that the exact old 2 GiB error or the OOM reproduces on current main or 4.2-dev.
Expected Behavior
CN spill and object writing should handle large or skewed variable-length input without an avoidable oversized block, excessive memory amplification, or failure solely due to speculative capacity growth. Correctness, row order and transactional semantics must be preserved. A single indivisible large row and real resource exhaustion need explicit, safe handling; a soft byte threshold alone cannot guarantee a hard memory bound.
Steps to Reproduce
Observed on the build listed above:
- Execute a large update against a table with variable-length columns and trigger a sorted CN spill.
- A spill reaches
WriteWithCompresswith a roughly 1.031 GiB serialized column. - The old capacity rounding requests 2 GiB from mpool and the query fails.
The precise data distribution and minimal standalone SQL reproducer for this incident have not yet been established. On current branches, construct deterministic CN-sinker coverage with skewed variable-length values and instrument output block sizes and peak memory; separately test the applicable chunked-column policy. Do not treat the old-build failure as proof of the same failure on a fixed build.
Additional information
Investigate a byte-aware boundary in the existing CN output path, including both general and disjoint-range merges, without unnecessarily duplicating storage or execution paths. Evaluate the cost of checking size for ordinary rows and wide schemas. Account for input batches and serialization/compression scratch buffers, and verify whether oversized reusable buffers remain retained after success, cancellation, and errors on each branch.
Validation should cover values and ordering, update correctness, large/skewed values including a single oversized row, full and partial blocks, spill failure/cancellation, resource cleanup and retry, as well as normal-workload performance. Confirm what happens when the compression bound itself exceeds the allocator limit; changing the 2 GiB mpool limit alone is not a memory-bound solution.
Activity
fix: bound CN spill runs by bytes 4.2-dev (#32155)
fix: bound CN spill runs by materialized bytes (#32188)
XuPeng-SH commentedon Nov 6, 2026
QA 交接(main 的已合并范围,待验证)
PR #32188 已合入 main,merge SHA
57e7871e500e6e3d35fd352a092ee41b03a979fc。CN data/tombstone spill 在复制前按 materialized bytes 分段,保留单个超大行及已有对象/块格式,配合 workspace publication/cleanup ownership;另含 reconnect acknowledgement 和 sequence expiry identity 修复。已读 issue 全评论及完整 PR 讨论。后续审查未留未完成的本 issue 开发项;旧部署 2 GiB 分配失败/OOM 不能直接归为当前版本反例,也没有证明该查询单独导致生产 OOM。
真实证据归属:作者及早期审查报告拥有者包 normal/race、重复并发测试、一 CN SQL/回滚和受控内存/对象数对照;最新审查在对应 reviewed head 执行了5个 sequence 回归 normal/race及各100次 race,spill/reconnect 部分复用未变源代码的旧结果。一次小 tmpfs spill-budget 失败随后 full-package/isolated 重跑通过,触发未明。最终 head build 成功,UT/coverage/SCA/BVT 取消、CI Required 失败。以上均不是本轮执行;本轮没有本地实测或完整 CI 通过声明。
请 @Ariznawlll 验证一般/不相交范围及 sorted/unsorted spill、宽变长与单超大行、数据顺序/事务更新、完整/末尾块、多对象/tombstone handoff、取消/失败/cleanup retry、reset/rebind和保留的早期事务语句,并复核 reconnect/sequence 边界。按真实存储记录性能、峰值和保留内存,不只记录逻辑阈值。
边界:这是 materialized-run 软预算,不是 RSS/全 pipeline/arena 硬上限;单行可超限,FileService 取消需协作,失败的 unbound cleanup owner 被丢弃可能留孤儿,shared arena 可保留 scratch,更多对象有性能成本。崩溃恢复、多 CN、真实生产负载及历史部署效果未建立。本次转测不表示这些边界已验收,也不自动要求 4.2 backport。
slyunnn commentedon Nov 6, 2026
Regression and extended verification for #32146 (2026-11-06)
Verification Environment
main, frozen from the remote at the start of testing:b6c57d315c8d1df2aca40ab19dee72136e6f2f81, fix(disttae): preserve optimistic RC write dependencies across snapshot advances (fix(disttae): preserve optimistic RC write dependencies across snapshot advances #32174).1.27.1. Binary build information andgit_version()at every SQL endpoint identifiedb6c57d315c; the owned service was restarted before the accepted runs. No MatrixOne tracked source or configuration was changed.3 CN / 1 TN / 1 Log service / Proxy, with a common DISK-V2 SHARED store. Proxy127.0.0.1:6001, CN1127.0.0.1:16001, CN2127.0.0.1:16002, and CN3127.0.0.1:16003were all reachable. Endpoint-specific execution is listed below.What Was Covered
cn_spill_byte_bound.sqlpassed34/34statements, twice at each of Proxy, CN1 and CN2. It checks multiple physical objects, update commit/rollback and variable-length-key delete/rollback. CN3 connectivity is separate from this BVT execution evidence.128 MiBCN budget, real SQL on each of Proxy, CN1 and CN2 populated sorted and unsorted LONGTEXT tables with1,024rows of192 KiBeach (192 MiBper fixture). Each produced2initial objects. UPDATE visibility, rollback to original contents, commit and reads through all three endpoints passed.2rows of96 MiBeach produced1object without bounded runs versus2with bounded runs. Full payload readback passed. Observed operation-owned peak live bytes were403111936versus201785344; this is a pool/resource observation, not process RSS or total query memory.136 MiBrow remained one correctly readable object, demonstrating the documented soft-budget exception. The bounded oversized-row probe released retained pool bytes on Reset; all probe modes reached0pool bytes after Close and input cleanup. The wide two-row bounded probe still retained201785344pool bytes after Reset, so Reset is not a general zero-retention guarantee.objectio/ioutilanddisttaefull-package race runs passed. Three critical spill failure/cancel/reset cases each passed100separate in-process race repetitions.50repetitions for terminal identity,100each for the other cases). Normal compile-package evidence was reused from the same unchanged commit.8,192-row ordinary fixture was measured in alternating bounded/unbounded order for4rounds. Median Write/Sync time was approximately7.92 msbounded versus7.14 msunbounded. This small shared-host probe shows an observed cost, not a production performance SLO or a speedup claim.4.2deployment, original unknown incident data/query distribution, production OOM causality, hard RSS bounds, crash recovery and a TKE production-load benchmark.Findings
Fix: PR #32188,
57e7871e500e6e3d35fd352a092ee41b03a979fc, fix: bound CN spill runs by materialized bytes. The tested main contains this fix.The materialized-byte boundary is applied before copying ordinary CN data/tombstone spill runs. Correctness and transaction/failure ownership checks passed. The contract is a soft run budget: one indivisible row can exceed it, input/compression/shared-arena memory can remain significant, and FileService cancellation requires cooperation. This does not establish a hard bound for the entire pipeline or show that a historical production OOM had a single cause.
MOTR / BVT Coverage
Reused the maintained
cn_spill_byte_bound.sqland owning-package regressions; no duplicate MOTR case was added. The live BVT/fault scenarios ran serially because they mutate fault points and the BVT runner performs database cleanup. Unit processes used independent fixtures; pipeline/concurrency paths were tested directly rather than inferred from runner-j.Large-data regression: required and completed locally at the relevant byte boundary, using
192 MiBSQL fixtures, the2 × 96 MiBdisk comparison and the indivisible136 MiBrow. More unrelated rows or an arbitrary TKE volume increase would not strengthen the byte-boundary assertion. Test databases were removed and the owned cluster shut down cleanly.Final Conclusion
Fixed for the main CN spill materialized-run budget and lifecycle contract verified above. This conclusion does not assert historical
4.2backport behavior, zero performance overhead or a hard process-memory/OOM guarantee.fix(import): preserve object layout and bounded metadata ownership (#…
fix(import): bound memory and pipeline uploads on 4.2-dev (#32065)
Fix large-value write memory usage on v4.2.8-hotfix (#32710)
fix: bound CN spill runs by bytes 4.2-dev (matrixorigin#32155)