Repository navigation
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? |
LeftHandCold
left a comment
There was a problem hiding this comment.
Code-review conclusion: APPROVE recommendation, no confirmed blocker at c471b864965be56102301d484cc5c0faba750e67.
Reviewed the complete four-file diff against 401d153150d9076f84aaaf2a32cdcf880b478395, including the #29571 reproduction and reverse consumers of the disjoint-layout proof. This is an ordinary performance bug fix, not a feature/design expansion.
The proof is preserved only for a flat destination with an existing disjoint-layout proof and owned data/area backings. Repeated selections and constant sources append independently copied spans; an already aliased or borrowed destination does not acquire a new proof. Reused NULL slots are initialized before restoring the proof, while a window destination does not clear its owner's descriptor. Allocation errors after publication leave the proof false. BackingKind is release authority rather than a global alias refcount; the review did not assume it makes concurrent mutation or owner reset safe while an outstanding legacy view is being consumed.
The ordinary metadata shortcut was checked field by field: skipped length processing only maintains sidecars that the guard requires to be nil; active binary/text metadata is excluded; the all-NULL prefix still clears scalar parameter identity; a pending string-source preflight forces the existing slow/finalize path. Batch/list-expression/masked-function/window/topN/mergeorder callers retain their contracts.
Ownership/unhappy-path closure:
| Dimension | Result |
|---|---|
| Q1: ownership/cleanup | No new buffer or lease owner; existing Vector.Free, merge pool reuse and HashBuild error cleanup remain effective. |
| Q2: termination | No new wait, goroutine, lock or cancellation dependency. |
| Q3: retained growth | No new retained container; payload copying is unchanged, merge output is block-bounded, and reset/reuse retains the existing lifetime. |
Traced direct/canonical marshal, UnionBatch's whole-area path, objectio writer/chunked-column admission, Sirius sizing and HashBuild recovery projection. These consumers require independent bounded payload spans, not descriptor offsets sorted by logical row. The existing chunked-column protocol/policy gate remains intact; this change does not introduce a wire-format version. The corresponding existing chunked/legacy-column and HashBuild tests are the right dependent evidence, as listed in the PR.
The six-row merge regression test genuinely forces the per-row path with interleaved key ranges and checks ordering, row count, payload roundtrip and output-buffer reuse. The delivered benchmark measures merge plus serialization using the same interleaved inputs, retained buffer capacity and timer-excluded setup. The author-reported before/after results support the vector/merge hot-path improvement, not full SQL/BigData speedup or native-memory peak. The acknowledged isolated BIGINT marshal control is not hidden.
Evidence: the PR reports the complete vector/batch/mergeutil suites, focused objectio/HashBuild controls, changed-package lint and sequential same-native benchmarks. Independently verified that the merge from tested implementation aa618881 to current head changes only the unrelated prepared-DECIMAL SQL/result pair; CGo/thirdparty/module inputs are unchanged. git diff --check passed and this review checkout is clean. Shared Build is successful in run 37021841981; full UT/SCA/BVT/coverage are still running, so this review does not claim final CI acceptance. No additional local Go build, broad UT, cluster or BigData workload was started.
GitHub's authenticated account is also the PR author (LeftHandCold), so GitHub does not permit a formal self-APPROVE. This COMMENT records the independent code-review recommendation; it is not a claimed APPROVED review-state change.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Approved at c471b864965be56102301d484cc5c0faba750e67, against base/merge-base 401d153150d9076f84aaaf2a32cdcf880b478395. No blocking findings after reviewing all four changed files, #29571, existing comments, and downstream consumers. No subagents or product-code changes.
Design and correctness
The fix belongs in the existing Vector.UnionOne owner: it retains an already valid disjoint-area proof after independently copying a value, instead of making every consumer rediscover the layout. It does not add a storage format, parallel execution path, cache, or state machine.
The proof remains restricted to a flat destination with an existing proof and owned data/area backings. Repeated selections and const sources copy independent payloads. Borrowed or already-aliased destinations do not acquire the proof. Reused NULL descriptors are initialized before restoring it; window destinations do not overwrite their owner's NULL descriptor. Payload-allocation failure leaves the proof false. This does not change the existing lifetime restriction on mutating/resetting owners while legacy views are in use.
The ordinary-metadata shortcut is consistent with its excluded states: absent sidecars need no length maintenance; active runtime string domains remain on the original path; an all-NULL prefix still resets parameter identity; pending string-source preflight forces finalization even when its sidecar has collapsed. Traced batch, list-expression and masked-function callers as well as reset/reuse.
Checked both producers and consumers: canonical/bulk marshal, UnionBatch whole-area copying, objectio legacy/chunked writers and readers, Sirius sizing, and Hashbuild recovery projection. The relevant invariant is non-overlapping bounded payload spans, not monotonically increasing descriptor offsets. Existing wire representations and chunked-column admission policy are retained.
Q1–Q3: no new allocation owner or retained collection, no new wait/lock/goroutine, and existing payload admission, block-bounded merge output and Reset/Free ownership remain in force.
Independent validation and QA
On Go 1.26.4, darwin/arm64, with native artifacts independently built from this head (make -j8 cgo):
- Full
pkg/container/vector,pkg/container/batch, andpkg/objectio/mergeutilsuites passed withmo-cgo-test -v -count=1 -timeout=180s. - Focused objectio
TestChunkedColumn*,TestReadLegacyColumnWindow*,TestLegacyColumnDecoder*, and HashbuildTestRecovery.*Projection.*/TestRuntimeFilterMarshal*passed. These include malformed-input rejection, shared-area fallback, memory admission and cleanup controls. - Two additional reviewer-only Go-overlay tests passed: (1) a disjoint area with holes/nonmonotonic offsets, followed by UnionOne, bulk UnionBatch into a nonempty destination, and decoded-value checks; (2) allocation failure followed by Reset and successful reuse of the same vector, with marshal roundtrip and zero remaining mpool allocation. No repository test/source edits were required.
gofmtandgit diff --checkpassed; the review checkout is clean. Every test process above reached terminal exit 0.
Implementation is +44/-25 (net +19); tests are +360 across three files; documentation is unchanged. The tests cover distinct layout eligibility, metadata transitions, and actual interleaved merge/serialization/reuse contracts rather than duplicating large fixtures. The six-row merge test forces the per-row path; large row counts are confined to the benchmark.
Performance and scope
The PR's matched Linux/amd64 before/after benchmarks support the vector and real merge-consumer improvement; their source freshness was checked across the unrelated final main merge. Separately, running the delivered interleaved merge+marshal benchmark at this head (GOMAXPROCS=1, 3 x 300ms) produced 0.728–0.789 ms/op and 31 allocs/op on Apple M4. This is a current-head sanity check, not a cross-platform before/after comparison.
The optimization removes avoidable metadata work and canonical per-descriptor emission without adding allocation/synchronization machinery. Full SQL/BigData wall-time recovery and native peak-memory reduction are not established by these component measurements and are not claimed by this approval.
No unresolved review threads or actionable prior requested-change findings exist. At submission preflight, shared build, preflight and coverage had succeeded; full UT/SCA/BVT were still running. This is the completed code-review decision, not a claim that all CI has finished.
Merge Queue Status
This pull request spent 14 minutes 13 seconds in the queue, with no time running CI. ReasonPull request #29573 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [x] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #29399 on `main`; forward-ports the remaining fixes from #29431 (`4.2-dev`). ## What this PR does / why we need it: Repeated restore can mistake CLONE provenance or a view definition for legacy CHECK metadata, lose ownership/current grants, or preserve revoked authorization in an existing connection. Partial restore also treated a role name as identity: renaming an owner blocked restore, while reusing its old name could transfer DROP authority to a different role. - Preserve structured CHECK recovery; recognize CLONE provenance and exclude view definitions from legacy table CHECK parsing. - Recreate objects under historical creator/owner IDs. Partial restore validates and pins required live principals within their physical catalog generation. Role renames preserve identity; name reuse cannot acquire ownership. Table restore locks and retains an existing database without requiring its historical creator/owner. - Resolve partial restore's historical logical source once, including existing view dependency planning, before ownership checks and destructive DDL. Ownership lookup intersects that source after existing external-table and unservable-view omissions. Execution reuses the same objects and classifications; FK/master/publication guards can still reject or omit candidates. This prevents an irrelevant deleted view principal from blocking ordinary data restoration, without exempting servable views. Explicit external-table restore still rejects; skipped single-view restore preserves the live view. - Full account restore rebuilds principal catalogs and can rewind their auto-increment IDs. **Partial restore across rebuilt catalogs rejects ordinary custom principals before DROP, even if IDs/names match or full restore legitimately reconstructed them.** Only reserved bootstrap identities with verified IDs/names and required direct admin grants can cross that boundary. Use a point in the current catalog generation or full restore; documented in `docs/ai-skills/backup-restore.md`. - Keep principal pins and current scoped grant capture/rebinding in the existing restore transaction. DROP USER/ROLE use private pessimistic RC transactions to honor those locks even under ordinary optimistic SI. Partial restore preserves current grants; full/cross-account catalog rebuilding retains its mapping. - Apply existing DATA BRANCH authorization to ordinary-user CLONE, preserving administrator historical/cross-account behavior, subscription errors and recreated publisher identity mapping. - Recheck authorization in existing and text/binary prepared connections across CNs. Within one privilege evaluation, deduplicate only identical SQL misses while retaining ordered errors, early hits and role/view scope. An enum-bounded stack buffer satisfies SCA preallocation without suppression or extra persistent authorization state. The upstream merge at `54af0d38290c66b61ac78a46aa07a363eb576aae` is preserved, including #29563 ESQL and #29568 FULLTEXT2/HNSW coordinator placement. No force push, workflow change or merge-policy bypass. ### Validation Go 1.26.4 / macOS ARM64, verified native provenance. Latest source-selection correction (`93405cdc0ea`): - Authenticated public SQL regression covers snapshot/PITR, independently deleted view creator/owner, ordinary-table data recovery, skipped live-view ID/definition/result preservation, and servable-view missing-principal rejection before DROP. Existing external rejection, retained/recreated DB and unchanged principal-generation controls remain. - Ownership tests cover excluded raw physical metadata, required servable views/sequences and fail-closed missing ownership. FK lookup tests verify shared pointers and scope without fresh enumeration. - After preserving the upstream merge: full frontend **26.886 s**, all six `TestIssue29399*` public tests **31.475 s**, and configured incremental golangci-lint **0 issues**. The byte-identical correction also passed all six tests under race detection before the merge (**69.920 s**). Go vet and repository molint completed with exit 0; existing molint recover diagnostics outside changed code are retained. No linter suppression/configuration weakening. Unchanged evidence from the whole-PR review is retained: planner/compiler and V406 maintenance tests; prepared/cache/active-role controls; normal BVT comparisons including metadata (ownership/CLONE 125/125, builtin full-then-partial 213/213, cache 37/37, revoked-role 39/39). The inherited target merge separately passed compiler/index owning packages and two-CN FULLTEXT2/HNSW rebuild integration. Its initial `TestConnMeasuresDelayedBufferedFlush` timing failure remains recorded; isolated repetitions and subsequent full frontend passed without weakening assertions. ### Performance and limitations Partial source selection adds bounded name maps, uses existing view planning once and avoids repeated partial source enumeration. It adds no persistent state, catalog format, principal query per object or new lock. Current-dependent runtime guards can conservatively omit a prevalidated candidate; this change does not claim exact prediction of every dynamic FK skip. Existing matched public microbenchmark: reader p50 median **1.617 → 1.333 ms (~17.6% lower)**; admin **243.5 → 244.3 µs**, with comparable controls. These local measurements do not recover the old stale-cache roughly 80 µs latency or establish production throughput. Authorization code is unchanged by the latest source-selection correction. The latest correction's design and final overall review use actual **gpt-6.1-sol / xhigh**, reconciling the whole-PR evidence with the changed paths. The source-selection correction's remote CI remains distinct from the target synchronization below; skipped jobs are not passes. ### Prior target synchronization and CI Prior synchronization head: `b190162ef097987a71e9252a49266caaee810451`; target `main`: `401d153150d9076f84aaaf2a32cdcf880b478395`. Normal merge parents are the preserved live `93405cdc0eafd1d2ce15a65d75d5afe2d531b36a` and the new target. This closes the observed strict-baseline BEHIND condition without rebasing, force-pushing or changing Ready/base state. Only #29570's two prepared-DECIMAL SQL/result files change relative to the first parent, byte-identically to the target; every other tracked file is unchanged. The existing source selection, ownership, current-grant transaction, authorization implementation and disclosed performance limits are preserved. Fresh monitor-local exact-merge binary build passes. The new upstream prepared-DECIMAL case passes strict JDBC metadata validation **213/213**, with named database cleanup zero (macOS ARM64 / Go 1.26.4 / Java 20). Independent read-only mechanical merge review approves and whitespace/worktree checks are clean. The prior `93405cdc` frontend/public/race proof above is external local unchanged-Go evidence, not a fresh whole-suite execution or current-head remote CI pass. No source-branch cache-certificate or internal-executor fix is blindly copied to main. XuPeng-SH approved `93405cdc` at 14:21 UTC after whole-PR follow-up; this is an actual submitted review, not the local mechanical approval. Prior-head Connector/J run [37015828472](https://github.com/matrixorigin/matrixone/actions/runs/37015828472) attempt 1 fails during ONNX Runtime download (HTTP 504), before the server/test. Exactly one failed-job rerun request was accepted. Attempt 2 / [110870725085](https://github.com/matrixorigin/matrixone/actions/runs/37015828472/job/110870725085) downloads the dependency and actually passes pool-reset tests for all four Connector/J versions at 14:07:46 UTC. That success belongs to `93405cdc`, not this new merge head. No healthy jobs or whole ALL CI run were rerun/cancelled and no build/workflow/tester/business workaround was added. That head's Connector/J [37023553819](https://github.com/matrixorigin/matrixone/actions/runs/37023553819) actually succeeds at 15:01:50 UTC; ALL CI remains unfinished when it is superseded by the next target merge. This is historical evidence, not a result for the current head. ### Prior target synchronization and validation Prior head: `380bbce20601196b9c9b09ea48089bb666985857`; target `main`: `5a09e1ffbf40a59f50c55fe89e6f0c23eba143a3`. After main merges #29567, strict protection marks the previous head BEHIND again. A normal merge preserves parents `b190162ef097987a71e9252a49266caaee810451` and the new target, without conflicts, manual overwrites, rebasing or force push. Its 15-file delta matches the upstream commit exactly, including modes and blob IDs. All existing PR changes from the approved implementation remain intact. Inherited prepared runtime-plan statistics admission does not bypass schema invalidation or text/binary EXECUTE reauthorization; shared restore source selection, ownership preflight and current-grant transactions are unchanged. Fresh monitor-local exact-head proof (macOS ARM64 / Go 1.26.4): - Full frontend/plan/hashmap **-race passes: 34.982 s / 36.546 s / 3.344 s**. - All six authenticated `TestIssue29399*` tests pass (**29.908 s**), including the eight optimistic-SI privilege-removal arms, snapshot/PITR ownership and source-selection boundaries, principal pins and invalid-grant rollback. Upstream reordered-join semantics and prepared workspace visibility tests pass (**13.031 s**), including integer/bigint/string/composite unique controls. The test-only atomic output `[no statements]` is not production coverage. - Exact binary build and version `380bbce206` pass. Configured incremental lint across all five upstream changed package roots reports **0 issues**. Worktree and whitespace checks are clean. Independent read-only merge/integration review approves; it checks inheritance and interaction, not the general upstream statistics policy. A fresh OPEN/Ready/head guard was awaited and read before the accepted normal push. Latest current-head CI is newly triggered and not complete; no BVT, full coverage, required-context or merge-gate pass is claimed. Prior-head successes are not substituted for current-head results. No workflow, tester or source cache-certificate/internal-executor framework is copied into main. Existing performance limitations and the separate constant-view issue #29572 remain unchanged. ### Current target synchronization and validation Current head: `ae4460f455bafa98a5beb301906adbd0abc522b6`; target `main`: `9078a8bd87af49ea06f52e09d64e7740122aea61` (#29573 vector UnionOne/marshal). Strict-baseline BEHIND is addressed by a normal merge with first parent `380bbce20601196b9c9b09ea48089bb666985857`, without conflict, manual overwrite, rebasing or force push. The four-file delta is byte/mode-identical to the upstream delta; the original 43-file PR patch remains identical against the new target. Restore source selection, ownership/current-grant transactions, principal-generation restriction, protocol/DAG and authorization implementation are preserved. Independent exact-merge local proof (macOS ARM64 / Go 1.26.4, verified inherited native inputs and absolute CGo paths): - Complete vector/batch/mergeutil **-race passes (6.392 s / 3.393 s / 3.712 s)**; complete frontend/plan **-race passes (34.427 s / 34.374 s)**. - All six authenticated `TestIssue29399*` plus authenticated fixture configuration pass **under race (65.232 s)**, including all eight optimistic-SI privilege-removal arms. Another 28 objectio/hashbuild marshal, recovery/area and runtime-filter consumer tests pass **under race (2.722 s / 2.297 s)**. - Configured incremental lint in the two upstream changed package roots: **0 issues**. Exact-head binary build/version, gofmt, whitespace and worktree checks pass. Native/packaged binary artifacts are preserved; the exact-head validation binary is separate. - Independent read-only integration/mechanical review **APPROVE**, covering ownership/aliasing, NULL reuse, errors, marshal and restore/clone consumers. This is local correctness evidence for this merge, not a GitHub approval, full BVT/BigData, Linux/GPU proof or performance comparison. Test-only atomic `[no statements]` is not production coverage. A fresh OPEN/Ready/head/body guard is awaited and read before the accepted normal push. The source-only SQL-task principal follow-up is not blindly copied into main's unchanged adapter/authorization path. Existing performance limitations and separate constant-view issue #29572 remain. Current exact-head [ALL CI run 37034311275](https://github.com/matrixorigin/matrixone/actions/runs/37034311275), attempt 1, completes **SUCCESS** at **2026-10-02 17:51:19 UTC**. Actual Ubuntu UT, arm64 SCA, shared build, UT Coverage, PROXY/PESSIMISTIC multi-CN BVT, Coverage and CI Required all succeed. The [CI Required log](https://github.com/matrixorigin/matrixone/actions/runs/37034311275/job/110959138144) confirms `full` scope, generation `37034311275-1`, all five dependency groups successful and `coverage_ready=true` / `coverage_status=passed`. The [Coverage log](https://github.com/matrixorigin/matrixone/actions/runs/37034311275/job/110952754024) selects UT and both complementary BVT profiles from that same generation and publishes the merged result. Current-head Connector/J succeeds; Iceberg is **SKIPPED**, not a functional test pass. No failed-job or whole-run rerun/cancellation is performed this round. The PR remains **OPEN / Ready / MERGEABLE / BLOCKED / APPROVED**. The retained approval was submitted on the earlier `93405cdc` implementation; it is not a new review of this target-merge head. All four discussion threads remain unresolved, with no new human findings. Completed CI Required and test jobs do not establish that every review/protection requirement has been satisfied; no Ready/base/approval/merge or protection policy is changed. --------- Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #29571.
What this PR does / why we need it:
General
MergeSortBatchescallsUnionOnefor each row and column. Although each varlen append copies its payload,UnionOneunconditionally discarded the destination's disjoint-area proof. Canonical marshal then rebuilt offsets and emitted descriptors individually, causing 8,233 allocations for an 8,192-row inline VARCHAR vector instead of 6. The ordinary fixed-width path also paid for absent metadata sidecars and redundant prefix processing.Preserve the existing proof only for a flat destination with uniquely owned descriptor and area buffers, after the appended descriptor/payload is initialized. Repeated selections and constant sources remain safe because each append copies independently. Allocation failures, borrowed buffers and preexisting aliases remain conservative. Owned NULL appends clear reused descriptors; shared windows retain their previous behavior without modifying their owner's descriptors.
The ordinary metadata branch skips absent-sidecar length publication and inactive preflight finalization. It retains allocation admission and the all-NULL prefix's parameter-identity reset. No SQL semantics, wire format, planner, concurrency or workflow changes.
Add focused coverage for mixed/repeated selections, constants, NULL/reset, borrowed and aliased storage, shared-window ownership, constant destinations, allocation failure and metadata transitions. The real merge consumer test uses overlapping key ranges to force
UnionOne, checks sorted values and marshal roundtrip, and reuses the output buffer. That consumer test fails on the unmodified base and passes with this fix.Validation
Linux/amd64, Go 1.26.4; independent
make cgofrom based59cc02ef6with verified native provenance. Both benchmark binaries use that same native build. Latest main401d153changes only unrelated prepared-DECIMAL SQL/result tests.Passed:
pkg/container/vector,pkg/container/batchandpkg/objectio/mergeutilsuites (-count=1 -timeout=180s) via the repository CGo wrapper.golangci-lintusing the repository configuration: 0 issues.gofmt,git diff --check, and independent complete-diff ownership/error/compatibility review.Before/after performance
Same host, sequential runs,
GOMAXPROCS=1,-benchtime=300ms -count=5; medians. Component probes use the issue's benchmark with its bug-expected assertion removed. The end-to-end merge benchmark is included in this PR.For the real merge consumer, allocated bytes fall from approximately 934 KB/op to 9.8 KB/op. Its keys are deliberately interleaved, avoiding the separate disjoint-concatenation optimization.
Reproduce the delivered consumer benchmark after
make cgo:Limitations: an isolated, unchanged BIGINT marshal control measured approximately 0.25 us slower in an alternating recheck; its allocation count stays 6 and the combined copy+marshal workload still improves by 21%. Its cause is not assigned, and this PR does not claim every microbenchmark improves. These results establish the vector regression and improvement in its actual merge consumer; they do not quantify whole SQL/BigData wall time or promise a return to 4.2's total runtime. No cluster or full BigData acceptance run was launched.