Repository navigation
fix(frontend): keep Decimal256 primary-key pairing in DATA BRANCH - #30837
Conversation
DATA BRANCH misclassifies changes on Decimal256 primary keys (DECIMAL precision 39..76). After one UPDATE of an existing row plus one INSERT, `DATA BRANCH DIFF ... OUTPUT SUMMARY` reports INSERTED 2 / DELETED 0 / UPDATED 0, so PICK and MERGE cannot apply the update; after one DELETE, DIFF returns an empty result and MERGE reports success while the base keeps the deleted row (silent sync loss). On current main the inline PICK/MERGE path also surfaces internal error 20101 carrying the vector.AppendAny conversion stack. Root cause: the branch hashmap packs Decimal256 keys with Packer.EncodeStringType over the raw 32 bytes, so DecodeRow returns the tombstone key element as []byte (decimal64/128 use their typed packer codes). findDeleteAndUpdateBat passed this raw element straight to vector.AppendAny on the Decimal256-typed tombstone PK vector, whose val.(types.Decimal256) assertion panics. In the async diff worker the ants pool recovers the panic and only logs it, silently skipping the whole tombstone-resolution step for that side; the PICK/MERGE onlineApply path runs the same code inline and re-raises the panic to the client. Change: append the decoded tombstone key element through appendTupleValueToVector -> normalizeTupleColumnValue, the shared normalization already used by every other decoded-tuple consumer in the data-branch code. Fixed-width raw payloads are converted to the typed value via types.DecodeValue before appending; typed, varlen and packed composite key encodings keep their existing behavior, and a malformed fixed-width payload now returns an explicit invalid-input error instead of a panicking type assertion. Tests: two focused deterministic unit tests drive the real hashDiff pipeline with the reported update and delete scenarios (both fail on the parent base with the production panic signature and pass with this change), plus a BVT regression covering the issue's UPDATE case, the issue comment's DELETE case and a DECIMAL(38,0) boundary control, executed by mo-tester with a generated, re-compared result file. Related to matrixorigin#28589
Address the three P3 findings from the pre-PR review: - release the retBatchList pools in both new hashDiff tests via freeAllRetBatches so the session mpool no longer reports outstanding on-heap allocations (304 bytes / 10 objects per test) at teardown - pin the exact surviving row in the BVT DELETE case by selecting d/note from both the branch and the base after the merge, so the case cannot pass if the wrong Decimal256 key is deleted - drop the branch_decimal256_pk database at the end of the BVT case The regenerated result file was re-verified in mo-tester run mode: 37/37 statements, 100%, and the database is confirmed absent after the run. Related to matrixorigin#28589
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? |
|
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: eaf87f129214b9552dc3c1e4d131191bf971fed2
Assessment: approve
Reviewed the complete four-file delta and affected callers. Reusing the existing tuple normalizer fixes Decimal256 tombstone decoding for DIFF, PICK and MERGE without changing key encoding or introducing duplicate logic. Error propagation and cleanup remain intact. Added work is constant per tombstone and does not affect ordinary SQL paths. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Traced encoding, typed-vector conversion, asynchronous and inline execution, error propagation and batch ownership.
-
Reviewed both new hashDiff regressions, existing normalization/error tests, and BVT expectations for updates, deletions, selected-key PICK, MERGE, Decimal128 compatibility and cleanup.
-
Frozen exact-head CI reports successful UT, coverage, SCA, shared build and both BVT groups.
-
git diff --check and evidence audit passed; command/source/exit receipts match retained logs. Source remained unchanged. Records: /home/xupeng/.local/state/mo-bot/jobs/5414a6b25721219284a917f2/attempt-1/evidence-audit.json and review-record.json.
Limitations:
-
No local Go tests or BVT rerun; reused exact-head CI evidence. Raw author/CI logs were not supplied, so author-reported runs were not independently replayed.
-
The linked issue body was absent; review covered the concrete update/delete scenarios captured in the PR.
-
No throughput benchmark was run or performance improvement claimed.
Merge Queue Status
This pull request spent 2 hours 35 minutes 1 second in the queue, with no time running CI. ReasonThe merge conditions cannot be satisfied due to failing checks
Failing checks: HintYou may have to fix your CI before adding the pull request to the queue again. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
Unrelated CI failure note: UT Coverage checkout timeout and downstream guards (tracked issue #28411)The Every build, test, and coverage step was skipped, so no MatrixOne code from this PR was ever fetched, compiled, or tested on that runner. This is a transient runner/network transport failure, the same infrastructure mechanism already recorded in issue #28411; a reproduction record for this occurrence has been posted there. Two further checks in the same run then failed purely as deterministic downstream consequences of that blocked producer, still with no MatrixOne source from this PR fetched or exercised:
This PR's own diff (frontend Decimal256 pairing fix plus its UT/BVT regressions) is unrelated to all of these failures. Positive evidence in the same run on the same head: CI preflight, coverage-eligibility, shared build and pr-size-label checks all succeeded, and the full non-coverage Recovery: the run reached its terminal failed state, so the single authorized failed-jobs rerun of run 39914038684 was triggered (attempt 2) at 2026-10-23T08:35:04Z; run status |
What type of PR is this?
Which issue(s) this PR fixes:
Related to #28589
What this PR does / why we need it:
DATA BRANCH misclassifies changes on Decimal256 primary keys (DECIMAL
precision 39..76). After updating one existing row and inserting one new
row on a branch,
DATA BRANCH DIFF ... OUTPUT SUMMARYreportsINSERTED 2 / DELETED 0 / UPDATED 0, so PICK and MERGE cannot apply theupdate; after deleting one row, DIFF returns an empty result and the
deletion never reaches the base: on the assignment base the failing
DATA BRANCH statements (PICK, MERGE and the DELETE-case MERGE) surface
internal error 20101 carrying the
vector.AppendAnyconversion stack,and on the older main snapshot from the issue comment the same
DELETE-case merge reported success while keeping the deleted row
(silent sync loss).
Root cause: the branch hashmap packs Decimal256 keys with
Packer.EncodeStringTypeover the raw 32 bytes, soDecodeRowreturnsthe tombstone key element as
[]byte(decimal64/128 use their typedpacker codes).
findDeleteAndUpdateBatpassed this raw element straightto
vector.AppendAnyon the Decimal256-typed tombstone PK vector, whoseval.(types.Decimal256)assertion panics. In the async diff worker theants pool recovers the panic and only logs it, silently skipping the
whole tombstone-resolution step for that side; the PICK/MERGE
onlineApply path runs the same code inline and re-raises the panic to
the client.
Change:
pkg/frontend/data_branch_hashdiff.goappends the decodedtombstone key element through
appendTupleValueToVector->normalizeTupleColumnValue, the shared normalization already used byevery other decoded-tuple consumer in the data-branch code.
Fixed-width raw payloads are converted to the typed value via
types.DecodeValuebefore appending; typed, varlen and packed compositekey encodings keep their existing behavior, and a malformed fixed-width
payload now returns an explicit invalid-input error instead of a
panicking type assertion.
Issue-to-test proof
TestHashDiff_HasLCADecimal256PKUpdateIsNotMisclassifieddrives thereal
hashDiffpipeline with the reported update scenario. It failson the parent base
6495ce9974(emits INSERT instead of UPDATE andthe log shows
ants: worker exits from panic: interface conversion: interface {} is []uint8, not types.Decimal256) and passes with thischange (exact UPDATE row; it also asserts the LCA probe embeds the
exact 40-digit Decimal256 literal with
cast(... as DECIMAL(40,0))).TestHashDiff_HasLCADecimal256PKDeleteIsReporteddrives the reportedsilent DELETE scenario. It fails on the parent base (no DELETE
emitted) and passes with this change (the DELETE before-image is
emitted).
test/distributed/cases/git4data/branch/edge/branch_decimal256_pk.sqlcovers the issue's UPDATE case (diff summary/count, selected-key PICK,
MERGE, base contents, final zero diff), the issue comment's DELETE
case (reported deletion, survivor-row identity in the branch and the
base, MERGE sync, final zero diff, database teardown) and a
DECIMAL(38,0) boundary control. The result file was generated against
the fixed binary by mo-tester, inspected against the intended
semantics, and re-run in compare mode: 37/37 statements, 100%. After
the run the branch_decimal256_pk database is confirmed absent from
the instance.
Test commands
.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -run 'TestHashDiff_HasLCADecimal256PK' -v ./pkg/frontend/— new UTs red on parent, green with this change; after the review hardening they release their batch pools and leave no outstanding mpool allocations at teardown..agents/skills/mo-dev/scripts/mo-cgo-test -count=1 ./pkg/frontend/databranchutils/and... -run 'TestHashDiff|TestHandleDelsOnLCA|TestCompare|TestFindDelete' ./pkg/frontend/— regression sweeps green (19 matched frontend data-branch tests plus the full databranchutils package).INSERTED 2/0/0, failing PICK/MERGE (ERROR 20101) and a silently unsynced DELETE; the fixed binary showsINSERTED 1/UPDATED 1, successful PICK and MERGE, final diff count 0, a synced deletion, and the unchanged DECIMAL(38,0) control.gofmt -lclean,GOWORK=off go vet -mod=readonly ./pkg/frontend/exit 0,golangci-lint run -c .golangci.yml --new-from-rev <base> ./pkg/frontend/...reports 0 issues.Validation, limitations and residual risk
Validation covers the two reported failure faces, the happy paths of
DIFF/PICK/MERGE for this key type, the malformed-payload error path and
the DECIMAL(38,0) boundary control. The full git4data BVT suite remains
for CI; no multi-CN or upgrade behavior is involved in the changed code.
The normalization is shared with all existing decoded-tuple consumers, so
no other primary-key kind (integers, fake PK, varchar/binary, packed
composite) changes encoding or comparison behavior. No residual risk is
identified beyond CI coverage of the full BVT suite.