Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
v4.2.1-hotfix and release/v4.2.1-hotfix-20261026. The relevant source files are identical to the v4.2.1 tag on both branches.
Commit ID
Reproduced against v4.2.1 commit d2393868a7aaa6343518d80849fe4696aa3577e9. At inspection, v4.2.1-hotfix was at 115c227239c65dfe36e14379d958033bf274f8f4 and release/v4.2.1-hotfix-20261026 at f6a27941d7185e3b406f7d45326ff9c86a9d1ff7.
Other Environment Information
- Linux amd64, Go 1.26.4.
- Diagnostic tests used the v4.2.1 source and locally available third-party native libraries; the provenance of those libraries was not fully verified.
Actual Behavior
Three paths lose ownership of vector resources:
Vector.CloneWindowTosets the destination'sdatato nil for a constant NULL source without freeing its existing owned buffer. In a real off-heap mpool test, a 10,485,760-byte allocation remained accounted after closing the destination and running Go GC; freeing the saved original buffer reduced the count to zero.getRowsByPKand its callers return on certain errors before registeringrowIDs.Close(). A deterministic injected duplicate-check error returned a vector still occupying one Small pool slot with 24 bytes retained. Closing it released the slot. The second caller at line 1242 has the same cleanup ordering.prepareApplyANodeborrows a new vector whenstartOffset == 0, but error returns do not close it before ownership transfers tonode.data. An injected schema mismatch left one pool slot in use with 24,576 bytes retained, using a pool slot seeded with a buffer.
Small-pool vectors use off-heap allocations. A separate pool diagnostic showed that an unclosed vector retained 10,485,760 bytes after Go GC, while Close() released it. The actual growth rate and production RSS impact of paths 2 and 3 have not been measured.
Expected Behavior
Each owned buffer or borrowed pool vector is released or transferred exactly once, including on error. Successful behavior and the existing write-write conflict handling remain unchanged.
Steps to Reproduce
- At the stated v4.2.1 commit, allocate an off-heap destination vector with a 10 MiB buffer from a real mpool. Clone a non-empty constant NULL vector into it using
CloneWindowTo, close both vectors, run GC, and inspectCurrNB(). Keep the original buffer reference in the test so it can be freed afterward. The count remains 10 MiB until the saved buffer is explicitly freed. - Create a table with a visible object whose
GetDuplicatedRowsreturns an injected error. CallgetRowsByPKwith a Small vector pool and inspect the returned vector andpool.Used(true)before closing it. It remains borrowed on error; the callers return before closing it for the relevant errors. - Seed a Small pool slot with an allocated rowid buffer and return it. Call
prepareApplyANodewithstartOffset == 0and an appender whoseIsSameColumnsreturns false. After the schema-change error, inspectpool.Used(true): the seeded slot remains in use.
Additional information
Focused diagnostic tests for all three paths passed against the stated tag. The tests for paths 2 and 3 use injected dependencies; they do not measure production frequency. The separate replaceCommitts/Dup failure candidate has not been validated and is outside this report.
Activity
[4.2.1-hotfix] Fix vector ownership on clone and transaction errors (#…
fix(vector): preserve const-null clone backing ownership (#31704)
[4.2] Fix vector ownership on clone and transaction errors (#31699)
XuPeng-SH commentedon Oct 29, 2026
QA handoff for merged #31704 (
1cea057047b7485736421842612c38d5667152ef): this isolated QA run inspected the source and issue history but did not run current-head functional tests or live SQL because the existing resource guard left insufficient headroom. Please verify const-NULL clone ownership, buffer leases and pool accounting. Author-reported PR tests are separate evidence and are not results of this QA run.MatrixAdventurer commentedon Oct 30, 2026
核实结论:已修复可关闭。
根因(pkg/container/vector/vector.go 的 clone_window_to 复用向量借入数据路径,约 L10810):克隆常量 NULL 窗口数据时未释放目标向量借入的 dataLease、未把 cantFreeData 置空,复用池向量随事务积累导致内存增长。修复已在三条涉及分支合入:main #31704(2026-10-29)、4.2-dev #31699、4.2.1-hotfix #31693。
证据:回归测试 TestVectorAllocationAccountConstNullCloneReuse、TestCloneWindowToConstNullReleasesDataLease(vector_test.go / buffer_lease_test.go)、TestCloneConstNullWithReusedPoolVector、TestCloneConstNullPoolAllocationLimit(vector_pool_clone_test.go)覆盖借入释放与池化复用,normal+race 均过;PR 自述复现脚本内存曲线由增长变为约 97MB 平坦。
还缺:无本轮可见缺口。
@Ariznawlll 请确认后关闭。本操作由LW授权的MOI智能体提交
slyunnn commentedon Nov 2, 2026
Regression and extended verification for #31690 (2026-11-02)
Verification Environment
ea184ad90624ae3dba8ced628ac019271a6c309c—fix: authorize exclusive SELECT lock targets (#31978).1.27.1, verified native-library provenance. Executable build metadata and runtimegit_version()identifyea184ad906.2 CN / 1 TN / 1 Log service / Proxy. Proxylocalhost:6001, CN1localhost:16001, CN2localhost:16002were reachable and each ran the constant-NULL and transaction-recovery SQL controls through PyMySQL/MySQL text protocol.What Was Covered
20allocations of at least10 MiB, each cloned from a non-empty constant-NULL source. After destination release and Go GC,mpool.CurrNB()returns to0every iteration.6directly affected clone/accounting/lease/pool tests also passed individually with-race -count=100.100iterations. Existing incremental-error and write-write-conflict tests pass, preserving the intentional conflict-result handoff.100times; pool usage returns to0, retained reusable bytes remain bounded, append lock bookkeeping balances, and pool destruction frees the remaining allocation. Normal and race modes passed.Findings
Main fix: PR #31704, merge
1cea057047b7485736421842612c38d5667152ef—fix(vector): preserve const-null clone backing ownership, included in this main snapshot. Owned backing remains reachable for reuse/free; borrowed data drops its own lease reference without releasing independent area ownership.The transaction paths have been refactored on main: non-conflict errors close candidates in the callee; write-write conflicts transfer the result to a caller that closes it; a newly borrowed append rowid vector is either closed on error or transferred into node data on success. Direct error injection validated the current paths rather than assuming old line numbers still identify the owner.
The tested error branches also release the append lock; no broader distributed-liveness claim is made. No new product defect was confirmed.
Related backports are merged: #31699,
260678bace0177678255089a23d0fe7d54cfc745, into4.2-dev; #31693,3391c6844e95d1bb27a647b18f48f7c3a5ba1695, intorelease/v4.2.1-hotfix-20261026. Merge status is not evidence that this QA run executed those branch binaries.MOTR / BVT Coverage
pkg/container/vector,pkg/vm/engine/tae/containers, andpkg/vm/engine/tae/txn/txnimplpackages passed in normal and race modes.Final Conclusion
Fixed on the tested main snapshot, with the original ownership failures covered by direct allocation and fault-injection evidence. Large-row-count regression is not required. A memory-boundary regression was required and completed using the reported
10 MiBscale and repeated error/reuse checks; arbitrary row growth or a TKE performance run would not improve this ownership oracle. This conclusion does not certify unexecuted release-branch binaries or production RSS behavior.