Repository navigation
[4.2.1-hotfix] Fix vector ownership on clone and transaction errors - #31693
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 02c88dab2d3cd93d1218a7d51d915ce71520cd52
Assessment: approve
The three ownership fixes preserve borrowed storage, node ownership transfer, and existing error semantics. Complete change and discussion review found no actionable defects.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Isolation preflight and native build from matching frozen inputs passed.
-
All three affected packages passed normally and under race: 215 tests each, no skips.
-
Seven regression tests each passed 100 focused race repetitions.
-
Scoped go vet, gofmt, and git diff --check passed.
-
validation-report.json reconciles 17 checks with source fingerprints, receipts, and retained logs. Discussion assessment is complete; source remains unchanged.
Limitations:
-
Validation used Linux amd64, Go 1.26.4, and TZ=UTC.
-
SQL BVT and production RSS/performance measurements were not run; the supplied CI snapshot provided no completed relevant validation.
Detailed review: ownership fixes and production TN memory attributionAssessment: the three Vector ownership fixes are justified and suitable for a hotfix candidate. No new blocking code defect was identified in this review. Production rollout remains gated; this is not yet proof that this PR eliminates all of the observed TN memory growth. Frozen review range:
1. What the PR actually fixes
Source: Const-NULL clone, GetByFilter, DedupSnapByPK, append ownership transfer. Important semantic checks:
These are the defects tracked in #31690. They should not be conflated with the separate 2. Evidence that the Const-NULL defect is reachable through a real TN consumerSeparate diagnostic work before this review exercised a real persisted-column reader, not just a direct call to the clone helper:
The fixture first populated a reusable destination buffer using a valid object containing the commit-TS column, then read valid objects without that column. Its allocator / ownership oracle produced:
The counterexample was observed on Darwin/arm64 and Linux/amd64. This proves a real TN consumer can lose native ownership on the original code, and that retaining owned capacity fixes that counterexample. Evidence reuse boundary: that diagnostic candidate used base 3. Why the production memory incident is not fully attributed yetAn anonymized TN observation around 2026-10-29 05:24 UTC / 13:24 CST recorded:
These are historical samples from this investigation, not a claim about the live state at the time someone reads this comment. Sampling times are close but not atomic, and these metrics must not be indiscriminately added together as disjoint RSS components. The acquired malloc profile covered approximately the FileService cache allocation total, not the 19.57 GiB of mpool allocations. It did not provide the native allocation stacks needed to assign that outstanding mpool balance to individual paths. The Go heap profile cannot fill that native allocation gap. One accounting distinction is particularly important here:
Therefore, the correct classification is:
Neither all 19.57 GiB nor the total RSS should be labelled as the amount this PR will necessarily eliminate. 4. Validation evidence and its limitsThe existing exact-head review reports Linux/amd64, Go 1.26.4, TZ=UTC; all three affected packages passing normally and under race (215 tests in each mode, no skips); seven regressions each passing 100 focused race repetitions; matching-input native build and static checks; and a 17-check That is meaningful revision-bound validation evidence. However, the raw report and retained logs were not available to this review for independent reconciliation. It would be useful to provide an accessible, appropriately redacted evidence artifact / location. This does not imply that those checks failed or did not run. Two test-boundary details should remain explicit:
The current completed GitHub checks are MongoDB E2E and Mergify checks, not full kernel validation. Also, the main CI entrypoint's target-branch filter does not include this 5. Separate retained-memory findings not fixed by this PRThese are not regressions introduced by #31693 and should not be folded into its proven production impact. A. B. Appender object-reference cleanup before registration. A source-level follow-up remains in the same append operation:
The concrete consequence is that 6. Hotfix / rollout decisionI support progressing this as a targeted ownership-fix candidate, subject to these release and incident-verification gates:
Bottom line: #31693 fixes real ownership defects and is a credible, narrowly scoped hotfix candidate. No new blocking defect was found in the changes reviewed. The remaining gates concern exact release validation and proving how much of the production incident it resolves; they do not justify claiming that all TN memory growth or all future OOM risk is already eliminated. |
## 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: Fixes #31690 ## What this PR does / why we need it: Forward-port the remaining constant-NULL clone ownership fix from #31693. Keep owned data capacity as a zero-length slice for reuse and eventual release. Release a borrowed data lease through its existing reference-counted owner, or detach a legacy alias, while preserving independent area ownership and existing runtime metadata handling. The transaction-vector errors from #31690 already have cleanup in this main base, so no transaction changes are included. Tests cover retained capacity/accounting, nil-mpool and legacy aliases, serialization and metadata reset, data-only and shared data/area lease release, pool reuse, and allocation-limit eviction. Validation: focused regressions and full normal/race tests for `pkg/container/vector` and `pkg/vm/engine/tae/containers`; incremental gofmt, go vet, repository-pinned molint and golangci-lint. Native prerequisites rebuilt from this base; tests use Go 1.27.1 and TZ=UTC. CI is pending. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
## 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: Fixes #31690 ## What this PR does / why we need it: Forward-port #31693 to `4.2-dev`. Preserve owned destination capacity when cloning a constant NULL, detach borrowed data safely, release returned row-ID vectors on both callers' error paths, and release newly borrowed append vectors until ownership transfers to the node. Existing write-write conflict continuation and positive-offset borrowing remain unchanged. Validation: focused regressions and full normal/race tests for `pkg/container/vector`, `pkg/vm/engine/tae/containers`, and `pkg/vm/engine/tae/txn/txnimpl`; incremental gofmt, go vet, repository-pinned molint and golangci-lint. Native prerequisites rebuilt from this base; tests use Go 1.26.4 and TZ=UTC. Regression coverage includes allocator/account balance, nil-mpool/alias controls, pool reuse/eviction, real lookup callers with cancellation/deadline and conflict controls, and append-vector error/transfer/borrowing paths. CI is pending.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #31690
What this PR does / why we need it:
Constant-NULL cloning can discard an owned destination buffer, and transaction error paths can abandon vectors borrowed from the Small pool. Retain owned destination capacity as a zero-length slice for reuse and eventual release, while detaching borrowed data safely. Register row-ID cleanup before either caller rejects an error, preserving write-write conflict continuation. Release newly acquired append vectors on failure until ownership transfers to the node; leave borrowed vectors under their existing owner.
Regression tests cover allocator/account balance, serialization, nil-mpool and borrowed-buffer controls, pool reuse and allocation-limit eviction, both actual lookup callers including cancellation/deadline errors and write-write conflict results, and append-vector early/late errors, successful transfer, and positive-offset borrowing. The new regressions fail against the original production code.
Validation: normal and race tests for
pkg/container/vector,pkg/vm/engine/tae/containers, andpkg/vm/engine/tae/txn/txnimpl; incremental gofmt, go vet, MatrixOne molint, and repository-pinned golangci-lint. Native prerequisites were rebuilt locally from this release base. Vector owning-package tests useTZ=UTC: the existingTestRowToStringfails in the host's New York timezone with the same signature on the original production code. These are internal ownership fixes with no intended SQL/error/protocol changes; no SQL BVT or performance benchmark was added. CI results are pending.