Skip to content

fix(disttae): backport exclusive relation handles to 4.1.6 hotfix - #31116

Merged
XuPeng-SH merged 1 commit into
matrixorigin:4.1.6-hotfixfrom
XuPeng-SH:codex/hotfix-relation-reset
Oct 25, 2026
Merged

XuPeng-SH merged 1 commit into
matrixorigin:4.1.6-hotfixfrom
XuPeng-SH:codex/hotfix-relation-reset

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Backport of #25634 (related to #25627) to 4.1.6-hotfix.

Addresses the prepared UPDATE JOIN race seen in PR #30977 CI. The same three conflicting writes reproduce on the clean hotfix base d315e9c993, independently of #30977.

What this PR does / why we need it:

A second execution of a prepared UPDATE JOIN lets Insert.Prepare and Deletion.Prepare concurrently reset the same transaction-cached relation. Reset overwrites its transaction operator, creation flag and snapshot, violating shared-relation ownership and triggering the race detector.

Backport the coherent ownership fix from main commit 7b34bfeb10ff645428af8284fa060912d086717b: keep canonical relations bound to their opening transaction and give each retaining operator an exclusive reusable handle. Reset resolves the current transaction's canonical relation and rebinds only the private handle; direct shared Reset is rejected. Migrate retained DML, scan, lock-metadata and multi-update relation consumers together, including reset-error propagation and partial initialization cleanup/retry. Preserve hotfix-specific partition and commit behavior.

Regression coverage includes concurrent independent handles, unchanged shared state, catalog misses, stale cache invalidation, txn-local CREATE/DROP, invalid workspaces/processes, DML handle reuse, lock retries and multi-update relation-ID cache rebinding. The existing binary-protocol prepared UPDATE JOIN regression validates affected rows and final values without a duplicate cluster fixture.

Validation

Linux/amd64, Go 1.26.4, clang/CGo, isolated test loopback and disk temporary storage; complete delta based on d315e9c993.

  • Clean-base reproduction: the exact prepared UPDATE JOIN test fails under -race with the three original Reset races. Fixed code passes the exact test twice under -race -short -tags=matrixone_test.
  • Concurrent relation-handle regression passes -race -count=100.
  • Full normal and race tests pass for pkg/vm/engine, disttae, memoryengine, pkg/sql/colexec, insert, deletion, lockop, and multi_update (483 root tests per mode).
  • Full compile normal testing reports the same three Parquet failures previously reproduced on clean d315e9c993: TestCompileExternScanParquetLoadUsesRowGroupFanoutWithEmptyFiles, TestCompileExternScanParquetRowGroupFanoutValidatesEmptyFileColumnCount, and TestCompileExternScanParquetLoadUsesFileFanoutMainPath. All remaining 277 root tests pass in normal and race modes, excluding only those three tests. The full compile suite is not claimed green.
  • Incremental go vet and configured golangci-lint v2.14.0 across all nine affected packages pass; lint reports zero new issues. Formatting, Apache headers and make err-check pass.

The cache-hit Reset path remains allocation-free in the regression oracle. Handles add one small owner-local allocation at acquisition, with no new per-row work, synchronization, background work, wire or disk format changes. CI for this new PR remains pending.

Design and final overall review completed by gpt-6.1-sol with xhigh reasoning; final review covers commit 046525a53d and reports zero unresolved material blockers. Review also corrected the regression fixture to close test-owned transaction clients and packer buffers; final affected-package and stress checks passed after that correction.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH

XuPeng-SH commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 046525a53d494ba4f6429e29ab131f5d8c230ed8

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 046525a53d494ba4f6429e29ab131f5d8c230ed8

Assessment: approve

Reviewed the complete 22-file delta and affected callers. Operator-owned handles correctly preserve canonical transaction bindings; serializing shared Reset would not solve that ownership problem. Caller migration, error propagation and partial-initialization cleanup are coherent. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Prepared UPDATE JOIN passed with -race on the candidate. Restoring all changed files to the frozen merge base reproduced the three original Reset races.

  • Full race suites for eight affected packages passed: 483 top-level tests. The existing TestFunctionFold placeholder was skipped.

  • Full compile race testing passed 277 tests and failed three Parquet tests. All three reproduced with matching assertion failures on the frozen merge base; the full suite is not claimed green.

  • Targeted race tests covered concurrent handles, unchanged shared bindings, catalog misses/invalidation, transaction-local CREATE/DROP, invalid inputs, DML reuse, lock retries and cleanup. The cache-hit Reset allocation oracle passed.

  • Isolation preflight passed. Recovered native artifacts were verified against 165 identical current-revision inputs and retained build receipts. Source remained unchanged; diff whitespace checks passed.

  • Commands, source fingerprints, exit receipts, log hashes and base-overlay provenance are reconciled in /home/xupeng/.local/state/mo-bot/jobs/09c224dd15bd63df607c4f95/attempt-1/validation-audit.json.

Limitations:

  • The three confirmed preexisting Parquet failures remain outside this PR’s scope.

  • Local execution used Linux/amd64, Go 1.26.4 and race-enabled tests. Full CI completion and author-reported lint results were not independently verified.

  • No SQL throughput benchmark was run. Additional handle allocation and lookup work occurs at acquisition/reset; no per-row work is added.

@XuPeng-SH
XuPeng-SH merged commit 9cdcce5 into matrixorigin:4.1.6-hotfix Oct 25, 2026
25 of 27 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/hotfix-relation-reset branch October 25, 2026 15:23
XuPeng-SH added a commit that referenced this pull request Oct 25, 2026
…30977)

## 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:

Related to matrixorigin/matrixflow#19631 and #25687.

## What this PR does / why we need it:

Covering-index rewriting can replace a selected shuffle column with
`serial_extract(...)` after Range Shuffle has been chosen. On
`4.1.6-hotfix`, aggregation constructors dereference a missing column
reference and ShuffleV2 rejects Range expressions. Preserve the selected
expression and its output type in JOIN/GROUP V1/V2 construction, then
route evaluated vectors through the existing Range implementation
without replacing input vectors or changing pool ownership.

Use unsigned arithmetic in the shared nullable uint64 min/max router so
high-bit keys retain the same bucket with or without NULLs.
Column/expression/serial_extract tests check high-bit and maximum uint64
values, NULL placement, clamping, exact row ownership, vector identity
and cleanup.

For empty remote dispatch, atomically claim a UUID and enqueue its
receiver under the registration lock. Reset closes registration, drains
queued receivers and owns terminal delivery. A healthy notification
first handled after 30 seconds still consumes the existing completion
tombstone and receives normal End; empty EOS no longer waits for it.
Capture the original cancellation function before publication, clean up
partially registered dispatches before failed startup returns, and
retain the existing nonempty-data and missing-producer bounds. No
wire-format change or additional worker/retry is introduced.

The Compose MinIO fixture explicitly selects amd64, propagates
bucket-setup errors and tolerates an existing bucket. The latest target
`4.1.6-hotfix@9cdcce5` is merged, retaining its disconnect/export
fixes, independent V1 uint64 correction (#31115) and exclusive
relation-handle backport (#31116), without duplicating those changes in
this PR. No planner strategy or pool implementation is replaced.

### Validation

Current review-fix validation uses Go 1.26.4 on macOS/arm64 with
matching native libraries:

- Full colexec, dispatch, shuffle, shuffleV2 and compile packages pass
normally and under race on the merged head. Unfiltered configured
golangci-lint **v2.6.2**, vet, gofmt, diff-check, err-check and license
checks pass.
- Deterministic registry/Dispatch/real-handler tests cover late lookup
at 60 seconds of virtual time, early/mixed notification, original
errors, query cancellation, disconnected transport, bounded nonempty
waits, registration rollback and generation reuse. Six focused lifecycle
tests pass **100 race iterations each**; changed-block coverage is
**65/65 statements (100%)**.
- Restoring only the old EOS wait reproduces the late healthy failure;
restoring only the old Reset reproduces missing terminal delivery for an
already-published receiver. Both counterexamples fail on their intended
assertions.
- `TestCoveringIndexShuffleSQL` passes all four query shapes on one and
three CNs under `-race -short -tags=matrixone_test`, including after
target integration. The prepared UPDATE JOIN second-execute race
regression also passes on that integrated target. Counts remain **270002
/ 134102 / 134100**.
- Unchanged SQL/result fixtures pass normal mo-tester comparison twice:
**27/27**, zero ignored/abnormal cases, verified schema teardown and
service health; the task-owned instance is stopped.

Earlier Linux/amd64 evidence at `45cfcd3f21` remains applicable to the
unchanged expression/routing contracts. Its three full-compile Parquet
fanout failures were reproduced on clean target `d315e9c993` in that
environment; no Parquet assertion was changed. The focused/macOS results
above do not establish full-repository Linux CI success.

---------

Co-authored-by: XuPeng-SH <[email protected]>

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants