Repository navigation
fix(data branch): support binary primary keys - #26559
Conversation
00e2779 to
1cb97c1
Compare
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review complete; no merge-blocking findings.
The new dispatch uses the same raw-byte lexicographic order as the ordinary batch sorter. BINARY(n) padding remains at the DML/cast boundary, VARBINARY length is preserved, and merge/sinker ownership and error propagation are unchanged. The unit and BVT coverage jointly exercise cross-batch ordering, byte prefixes, NUL/high bytes, fixed-binary padding, payload association, and branch isolation.
Independent verification on this exact head: build and vet passed; TestMergeSortBatchesBinaryTypes passed with -race -count=100; the complete mergeutil package passed under race; and the dependent objectio/ioutil package passed. Additional diagnostic coverage for out-of-line varlena values (BINARY(32) / VARBINARY(64)) also passed.
Q1: no new resource owner or cleanup edge. Q2: no new wait dependency. Q3: heap/output/staging bounds remain unchanged.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26075 ## What this PR does / why we need it: ### Root cause `DATA BRANCH CREATE TABLE` copies rows through the sinker spill-sort path. The ordinary batch sorter already supports `BINARY` and `VARBINARY`, but `mergeutil.MergeSortBatches` omitted both OIDs from its varlena dispatch. When either type was the primary-key sort key, multi-batch merge initialization reached the default branch and panicked with `invalid type: BINARY` or `invalid type: VARBINARY`. ### Changes - Route `BINARY` and `VARBINARY` sort keys through the existing varlena merge implementation, preserving the same raw-byte lexicographic ordering used by the ordinary sorter. - Add a focused merge-sort unit test for both types, including interleaved batches, byte prefixes, NUL bytes, high bytes, and payload/key association. - Add a self-contained Data Branch BVT covering fixed-binary padding, variable-binary byte preservation, ordering, successful table branch creation, and branch isolation. ### Tests - Pre-fix regression proof: `TestMergeSortBatchesBinaryTypes/binary` panicked at `pkg/objectio/mergeutil/types.go:120` with `invalid type: BINARY`. - `go build ./pkg/objectio/mergeutil` with the repository CGo environment. - `go vet ./pkg/objectio/mergeutil` with the repository CGo environment. - After rebasing onto `ffad68fdb`, `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s ./pkg/objectio/mergeutil`. - After rebasing, `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=300s -run '^TestMergeSortBatchesBinaryTypes$' ./pkg/objectio/mergeutil`. - After rebasing, `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/objectio/mergeutil`. - After rebasing, `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/objectio/ioutil`. - `mo-tester` BVT `branch_binary_pk.sql`: 3/3 runs passed, each 18/18 statements at 100%. - CI follow-up: run 30699038757 attempt 1 reproduced an unrelated `morpc` options-slice race tracked in matrixorigin#26562; the failed Ubuntu/x86 UT job passed on attempt 2, and the completed SCA, coverage, and BVT checks are green. ### Residual risks No known residual correctness risk. The change only admits two already-supported varlena types into the merge-sort dispatch; it does not alter storage formats, comparison rules, or behavior for unsupported types.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26075 ## What this PR does / why we need it: ### Root cause `DATA BRANCH CREATE TABLE` copies rows through the sinker spill-sort path. The ordinary batch sorter already supports `BINARY` and `VARBINARY`, but `mergeutil.MergeSortBatches` omitted both OIDs from its varlena dispatch. When either type was the primary-key sort key, multi-batch merge initialization reached the default branch and panicked with `invalid type: BINARY` or `invalid type: VARBINARY`. ### Changes - Route `BINARY` and `VARBINARY` sort keys through the existing varlena merge implementation, preserving the same raw-byte lexicographic ordering used by the ordinary sorter. - Add a focused merge-sort unit test for both types, including interleaved batches, byte prefixes, NUL bytes, high bytes, and payload/key association. - Add a self-contained Data Branch BVT covering fixed-binary padding, variable-binary byte preservation, ordering, successful table branch creation, and branch isolation. ### Tests - Pre-fix regression proof: `TestMergeSortBatchesBinaryTypes/binary` panicked at `pkg/objectio/mergeutil/types.go:120` with `invalid type: BINARY`. - `go build ./pkg/objectio/mergeutil` with the repository CGo environment. - `go vet ./pkg/objectio/mergeutil` with the repository CGo environment. - After rebasing onto `ffad68fdb`, `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s ./pkg/objectio/mergeutil`. - After rebasing, `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=300s -run '^TestMergeSortBatchesBinaryTypes$' ./pkg/objectio/mergeutil`. - After rebasing, `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/objectio/mergeutil`. - After rebasing, `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/objectio/ioutil`. - `mo-tester` BVT `branch_binary_pk.sql`: 3/3 runs passed, each 18/18 statements at 100%. - CI follow-up: run 30699038757 attempt 1 reproduced an unrelated `morpc` options-slice race tracked in matrixorigin#26562; the failed Ubuntu/x86 UT job passed on attempt 2, and the completed SCA, coverage, and BVT checks are green. ### Residual risks No known residual correctness risk. The change only admits two already-supported varlena types into the merge-sort dispatch; it does not alter storage formats, comparison rules, or behavior for unsupported types.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#26075 ## What this PR does / why we need it: ### Root cause `DATA BRANCH CREATE TABLE` copies rows through the sinker spill-sort path. The ordinary batch sorter already supports `BINARY` and `VARBINARY`, but `mergeutil.MergeSortBatches` omitted both OIDs from its varlena dispatch. When either type was the primary-key sort key, multi-batch merge initialization reached the default branch and panicked with `invalid type: BINARY` or `invalid type: VARBINARY`. ### Changes - Route `BINARY` and `VARBINARY` sort keys through the existing varlena merge implementation, preserving the same raw-byte lexicographic ordering used by the ordinary sorter. - Add a focused merge-sort unit test for both types, including interleaved batches, byte prefixes, NUL bytes, high bytes, and payload/key association. - Add a self-contained Data Branch BVT covering fixed-binary padding, variable-binary byte preservation, ordering, successful table branch creation, and branch isolation. ### Tests - Pre-fix regression proof: `TestMergeSortBatchesBinaryTypes/binary` panicked at `pkg/objectio/mergeutil/types.go:120` with `invalid type: BINARY`. - `go build ./pkg/objectio/mergeutil` with the repository CGo environment. - `go vet ./pkg/objectio/mergeutil` with the repository CGo environment. - After rebasing onto `ffad68fdb`, `.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s ./pkg/objectio/mergeutil`. - After rebasing, `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=300s -run '^TestMergeSortBatchesBinaryTypes$' ./pkg/objectio/mergeutil`. - After rebasing, `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/objectio/mergeutil`. - After rebasing, `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/objectio/ioutil`. - `mo-tester` BVT `branch_binary_pk.sql`: 3/3 runs passed, each 18/18 statements at 100%. - CI follow-up: run 30699038757 attempt 1 reproduced an unrelated `morpc` options-slice race tracked in matrixorigin#26562; the failed Ubuntu/x86 UT job passed on attempt 2, and the completed SCA, coverage, and BVT checks are green. ### Residual risks No known residual correctness risk. The change only admits two already-supported varlena types into the merge-sort dispatch; it does not alter storage formats, comparison rules, or behavior for unsupported types.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26075
What this PR does / why we need it:
Root cause
DATA BRANCH CREATE TABLEcopies rows through the sinker spill-sort path. The ordinary batch sorter already supportsBINARYandVARBINARY, butmergeutil.MergeSortBatchesomitted both OIDs from its varlena dispatch. When either type was the primary-key sort key, multi-batch merge initialization reached the default branch and panicked withinvalid type: BINARYorinvalid type: VARBINARY.Changes
BINARYandVARBINARYsort keys through the existing varlena merge implementation, preserving the same raw-byte lexicographic ordering used by the ordinary sorter.Tests
TestMergeSortBatchesBinaryTypes/binarypanicked atpkg/objectio/mergeutil/types.go:120withinvalid type: BINARY.go build ./pkg/objectio/mergeutilwith the repository CGo environment.go vet ./pkg/objectio/mergeutilwith the repository CGo environment.ffad68fdb,.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s ./pkg/objectio/mergeutil..agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 -timeout=300s -run '^TestMergeSortBatchesBinaryTypes$' ./pkg/objectio/mergeutil..agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=300s ./pkg/objectio/mergeutil..agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/objectio/ioutil.mo-testerBVTbranch_binary_pk.sql: 3/3 runs passed, each 18/18 statements at 100%.morpcoptions-slice race tracked in [Bug]: concurrent morpc backend creation races on factory options #26562; the failed Ubuntu/x86 UT job passed on attempt 2, and the completed SCA, coverage, and BVT checks are green.Residual risks
No known residual correctness risk. The change only admits two already-supported varlena types into the merge-sort dispatch; it does not alter storage formats, comparison rules, or behavior for unsupported types.