Skip to content

fix(disttae): strengthen reusable relation handle reset coverage and correctness - #25634

Merged
XuPeng-SH merged 1 commit into
mainfrom
refactor/issue-25627-relation-lifecycle
Jul 12, 2026
Merged

XuPeng-SH merged 1 commit into
mainfrom
refactor/issue-25627-relation-lifecycle

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

Why

This PR addresses correctness and unhappy-path coverage gaps in relation-handle reset behavior under reusable relation lifecycle, especially during cache misses and DDL race cases around table existence and deletion.

What changed

  • Add missing unhappy-path tests for reusableRelationHandle.Reset in pkg/vm/engine/disttae/txn_table_test.go.
    • TestReusableRelationHandleResetFromCatalogCacheMiss covers tableOps and tableCache misses and verifies rebind via catalog path.
    • TestReusableRelationHandleResetFromCatalogMissingTable covers catalog lookup miss after lookup and returns NoSuchTable.
    • TestReusableRelationHandleResetRejectsDeletedTable covers existAndDeleted returning true after DDL drop and returns NoSuchTable.
    • combinedTxnTable.Reset behavior and shared reset semantics are explicitly validated.
    • Added test helpers newResetTxnForTest and insertCatalogTableForResetTest for realistic catalog-backed reset scenarios.

How it fixes the issue

  • Avoids blind reliance on cache-hit paths by exercising catalog-rebind and failure paths that were previously untested.
  • Makes table-drop race behavior explicit and deterministic in tests.
  • Confirms shared/combined reset behavior remains constrained while operator-owned reusable handles rebind correctly.

Performance

  • No new hot-path overhead expected for cache-hit reset path.
  • Cache-miss reset remains an exceptional path and can involve canonical reconstruction as designed.

Related

@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 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.

Reviewed the full relation lifecycle and all changed call sites. I found no blocking correctness, concurrency, lifecycle, compatibility, or performance issue.

Verified closures:

  • shared disttae canonical relation -> exclusive reusable handle -> per-execution Reset/rebind
  • tableCache hit, catalog cache miss, txn-local DROP, txn-local CREATE, and non-disttae workspace failure paths
  • table scan, insert, delete, lock, multi-update, and LockMeta retained-relation call sites
  • partial Prepare/initialization failures preserve a retryable state

Local verification:

  • targeted affected-package tests passed
  • reusable relation reset tests passed under -race -count=5
  • changed operator/compile tests passed under -race -count=3

The cache-hit reset path remains allocation-free according to the added benchmark assertion; catalog reconstruction is confined to the cache-miss path. GitHub does not allow approving one's own PR, so this is recorded as a non-blocking review comment.

@XuPeng-SH
XuPeng-SH merged commit 7b34bfe into main Jul 12, 2026
28 checks passed
@XuPeng-SH
XuPeng-SH deleted the refactor/issue-25627-relation-lifecycle branch July 12, 2026 01:51
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…correctness (matrixorigin#25634)

## Why

This PR addresses correctness and unhappy-path coverage gaps in
relation-handle reset behavior under reusable relation lifecycle,
especially during cache misses and DDL race cases around table existence
and deletion.

## What changed

- Add missing unhappy-path tests for `reusableRelationHandle.Reset` in
`pkg/vm/engine/disttae/txn_table_test.go`.
- `TestReusableRelationHandleResetFromCatalogCacheMiss` covers
`tableOps` and `tableCache` misses and verifies rebind via catalog path.
- `TestReusableRelationHandleResetFromCatalogMissingTable` covers
catalog lookup miss after lookup and returns `NoSuchTable`.
- `TestReusableRelationHandleResetRejectsDeletedTable` covers
`existAndDeleted` returning true after DDL drop and returns
`NoSuchTable`.
- `combinedTxnTable.Reset` behavior and shared reset semantics are
explicitly validated.
- Added test helpers `newResetTxnForTest` and
`insertCatalogTableForResetTest` for realistic catalog-backed reset
scenarios.

## How it fixes the issue

- Avoids blind reliance on cache-hit paths by exercising catalog-rebind
and failure paths that were previously untested.
- Makes table-drop race behavior explicit and deterministic in tests.
- Confirms shared/combined reset behavior remains constrained while
operator-owned reusable handles rebind correctly.

## Performance

- No new hot-path overhead expected for cache-hit reset path.
- Cache-miss reset remains an exceptional path and can involve canonical
reconstruction as designed.

## Related
- Fixes: matrixorigin#25627
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…correctness (matrixorigin#25634)

## Why

This PR addresses correctness and unhappy-path coverage gaps in
relation-handle reset behavior under reusable relation lifecycle,
especially during cache misses and DDL race cases around table existence
and deletion.

## What changed

- Add missing unhappy-path tests for `reusableRelationHandle.Reset` in
`pkg/vm/engine/disttae/txn_table_test.go`.
- `TestReusableRelationHandleResetFromCatalogCacheMiss` covers
`tableOps` and `tableCache` misses and verifies rebind via catalog path.
- `TestReusableRelationHandleResetFromCatalogMissingTable` covers
catalog lookup miss after lookup and returns `NoSuchTable`.
- `TestReusableRelationHandleResetRejectsDeletedTable` covers
`existAndDeleted` returning true after DDL drop and returns
`NoSuchTable`.
- `combinedTxnTable.Reset` behavior and shared reset semantics are
explicitly validated.
- Added test helpers `newResetTxnForTest` and
`insertCatalogTableForResetTest` for realistic catalog-backed reset
scenarios.

## How it fixes the issue

- Avoids blind reliance on cache-hit paths by exercising catalog-rebind
and failure paths that were previously untested.
- Makes table-drop race behavior explicit and deterministic in tests.
- Confirms shared/combined reset behavior remains constrained while
operator-owned reusable handles rebind correctly.

## Performance

- No new hot-path overhead expected for cache-hit reset path.
- Cache-miss reset remains an exceptional path and can involve canonical
reconstruction as designed.

## Related
- Fixes: matrixorigin#25627
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…correctness (matrixorigin#25634)

## Why

This PR addresses correctness and unhappy-path coverage gaps in
relation-handle reset behavior under reusable relation lifecycle,
especially during cache misses and DDL race cases around table existence
and deletion.

## What changed

- Add missing unhappy-path tests for `reusableRelationHandle.Reset` in
`pkg/vm/engine/disttae/txn_table_test.go`.
- `TestReusableRelationHandleResetFromCatalogCacheMiss` covers
`tableOps` and `tableCache` misses and verifies rebind via catalog path.
- `TestReusableRelationHandleResetFromCatalogMissingTable` covers
catalog lookup miss after lookup and returns `NoSuchTable`.
- `TestReusableRelationHandleResetRejectsDeletedTable` covers
`existAndDeleted` returning true after DDL drop and returns
`NoSuchTable`.
- `combinedTxnTable.Reset` behavior and shared reset semantics are
explicitly validated.
- Added test helpers `newResetTxnForTest` and
`insertCatalogTableForResetTest` for realistic catalog-backed reset
scenarios.

## How it fixes the issue

- Avoids blind reliance on cache-hit paths by exercising catalog-rebind
and failure paths that were previously untested.
- Makes table-drop race behavior explicit and deterministic in tests.
- Confirms shared/combined reset behavior remains constrained while
operator-owned reusable handles rebind correctly.

## Performance

- No new hot-path overhead expected for cache-hit reset path.
- Cache-miss reset remains an exceptional path and can involve canonical
reconstruction as designed.

## Related
- Fixes: matrixorigin#25627
XuPeng-SH added a commit that referenced this pull request Oct 25, 2026
…1116)

## What type of PR is this?

- [ ] API-change
- [x] 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](https://github.com/matrixorigin/matrixone/actions/runs/40170643192/job/121160646002?pr=30977).
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.

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

size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactoring]: Separate transaction-scoped relation state from reusable compiled operators

2 participants