Repository navigation
fix(disttae): strengthen reusable relation handle reset coverage and correctness - #25634
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
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.
…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
…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
…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
…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.
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
reusableRelationHandle.Resetinpkg/vm/engine/disttae/txn_table_test.go.TestReusableRelationHandleResetFromCatalogCacheMisscoverstableOpsandtableCachemisses and verifies rebind via catalog path.TestReusableRelationHandleResetFromCatalogMissingTablecovers catalog lookup miss after lookup and returnsNoSuchTable.TestReusableRelationHandleResetRejectsDeletedTablecoversexistAndDeletedreturning true after DDL drop and returnsNoSuchTable.combinedTxnTable.Resetbehavior and shared reset semantics are explicitly validated.newResetTxnForTestandinsertCatalogTableForResetTestfor realistic catalog-backed reset scenarios.How it fixes the issue
Performance
Related