Repository navigation
fix(plan): maintain irregular indexes in modern update - #26518
Merged
Merged
Conversation
Contributor
Merge Queue Status
This pull request spent 36 minutes 38 seconds in the queue, including 36 minutes 15 seconds running CI. Required conditions to merge
|
10 tasks
This was referenced Aug 14, 2026
XuPeng-SH
pushed a commit
that referenced
this pull request
Aug 14, 2026
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #27142 Related to #27124, #26925, and #26518. ## What this PR does / why we need it: ### Root cause #26518 moved synchronous IVF/full-text UPDATE maintenance to separate top-level steps that consume a shared materialized final-row image. The pre-existing base-table `LOCK_OP` remained downstream of that materialization in only the main `MULTI_UPDATE` consumer. The main consumer and hidden-index consumers could therefore acquire locks independently: ```text T1: base row -> waits for IVF entries row T2: IVF entries row -> waits for base row ``` Production logs after the false self-cycle fix in #26925 contain real cycles between two different transactions updating the same primary key. These are genuine wait edges, so changing deadlock detection would hide the symptom rather than repair the lock order. ### Fix For UPDATEs with synchronous irregular-index maintenance, move the existing base/regular-index `LOCK_OP` before the shared row-image `SINK`: ```text final row image -> existing LOCK_OP -> shared SINK -> base MULTI_UPDATE -> irregular delete maintenance -> irregular insert maintenance ``` Every downstream consumer now receives a row only after its base lock has been acquired. A second transaction updating the same primary key waits at that gate before it can acquire a hidden-table lock. This PR does not add locks or change lock modes, commit-time release, RPC formats, or lockservice behavior. UPDATEs without synchronous irregular maintenance keep their existing plan shape. Async indexes remain CDC-only. ### Risk assessment - Normal UPDATEs do not enter the changed branch. - Synchronous IVF/full-text UPDATEs execute the same lock operation earlier in the same transaction; uncontended lock work and lock cardinality are unchanged. - Lock failure/cancellation now happens before hidden-table maintenance starts, reducing partial-work exposure. - Existing embedded full-text coverage verifies blocking, cancellation, rollback, retry, and hidden-index consistency. ### Tests - Added a deterministic planner regression for both IVF and full-text asserting that the shared maintenance sink depends on the base-table lock. - Added a control asserting ordinary UPDATE keeps `LOCK_OP` directly at the DML input. - Verified the new invariant fails on unfixed main and passes with this PR. - `go build -mod=readonly ./pkg/sql/plan` - `go vet -mod=readonly ./pkg/sql/plan` - `go test -count=1 ./pkg/sql/plan` - `go test -race -count=1 ./pkg/sql/plan` - Focused planner regressions with `-race -count=100` - `TestIssue26341CancelAndRetryFulltextUpdate` embedded-cluster regression Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 of 7 tasks
XuPeng-SH
pushed a commit
that referenced
this pull request
Aug 17, 2026
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #27124 Backport of #27144. Related to #27142, #26925, and #26518. ## What this PR does / why we need it: ### Root cause #26518 moved synchronous IVF/full-text UPDATE maintenance to separate top-level steps that consume a shared materialized final-row image. The existing base/regular-index `LOCK_OP` remained downstream of that materialization in only the main `MULTI_UPDATE` consumer. The base consumer and hidden-index consumers could therefore acquire locks in opposite order: ```text T1: base row -> waits for IVF/full-text hidden row T2: IVF/full-text hidden row -> waits for base row ``` #26925 removes false self-cycles from deadlock detection, but it cannot remove these real two-transaction cycles. ### Fix For UPDATEs with synchronous irregular-index maintenance, move the existing base/regular-index `LOCK_OP` before the shared row-image `SINK`: ```text final row image -> existing LOCK_OP -> shared SINK -> base MULTI_UPDATE -> irregular delete maintenance -> irregular insert maintenance ``` Preserve the complete positional row image through the moved lock gate so all sink consumers continue to resolve the same columns. This is a semantic backport because the original main commit conflicts with the current 4.2 planner implementation. It retains #27144's lock-order invariant while adapting to the 4.2 UPDATE fanout helper. 4.2 does not support master-index UPDATE, so the regression covers its reachable IVF and full-text paths. ### Risk assessment - No new lock, lock mode, release rule, RPC, or lockservice behavior is introduced. - Normal UPDATEs keep `MULTI_UPDATE -> LOCK_OP`. - Synchronous IVF/full-text UPDATEs execute the same lock operation once, earlier in the same transaction. - Async indexes remain CDC-only. ### Tests - Verified the new planner regression fails on clean 4.2-dev `aaac5956fd` for both IVF and full-text because the maintenance fanout has no upstream base lock. - `pkg/sql/plan` full package test. - Focused planner regressions with `-count=10`. - `go vet ./pkg/sql/plan`. - `TestIssue26341CancelAndRetryFulltextUpdate` embedded three-CN regression, covering lock blocking, cancellation, rollback, retry, and hidden-index consistency.
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…26518) The modern UPDATE planner previously routed affected FULLTEXT and vector indexes back to the legacy planner because it could not maintain their hidden tables. This prevented the UPDATE planner migration from completing and made index behavior depend on planner fallback. This change keeps plugin-supported irregular indexes on the modern planner path: - classifies synchronous and asynchronous indexes through plugin metadata and update-column hooks; - materializes the final UPDATE row image once and shares it with the base-table mutation and synchronous hidden-index delete/insert plans; - keeps asynchronous indexes CDC-only; - rejects primary-key updates when a synchronous irregular index would otherwise retain hidden rows keyed by the old primary key; - covers indexed columns, included columns, implicit `ON UPDATE` columns, route selection, and legacy handling for algorithms not yet migrated to the plugin contract. Validation: - `make -j8` - `make static-check` - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 ./pkg/sql/plan` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 ./pkg/sql/plan` - focused planner tests with `-race -count=100` - `vector_ivfflat_include_dml_sync.sql` (25/25) - `fulltext_update_pk.sql` (21/21) - `fulltext.sql` (255/255) - manual transaction commit/rollback checks for synchronous FULLTEXT maintenance Approved by: @heni02, @XuPeng-SH
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…n#27144) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27142 Related to matrixorigin#27124, matrixorigin#26925, and matrixorigin#26518. ## What this PR does / why we need it: ### Root cause matrixorigin#26518 moved synchronous IVF/full-text UPDATE maintenance to separate top-level steps that consume a shared materialized final-row image. The pre-existing base-table `LOCK_OP` remained downstream of that materialization in only the main `MULTI_UPDATE` consumer. The main consumer and hidden-index consumers could therefore acquire locks independently: ```text T1: base row -> waits for IVF entries row T2: IVF entries row -> waits for base row ``` Production logs after the false self-cycle fix in matrixorigin#26925 contain real cycles between two different transactions updating the same primary key. These are genuine wait edges, so changing deadlock detection would hide the symptom rather than repair the lock order. ### Fix For UPDATEs with synchronous irregular-index maintenance, move the existing base/regular-index `LOCK_OP` before the shared row-image `SINK`: ```text final row image -> existing LOCK_OP -> shared SINK -> base MULTI_UPDATE -> irregular delete maintenance -> irregular insert maintenance ``` Every downstream consumer now receives a row only after its base lock has been acquired. A second transaction updating the same primary key waits at that gate before it can acquire a hidden-table lock. This PR does not add locks or change lock modes, commit-time release, RPC formats, or lockservice behavior. UPDATEs without synchronous irregular maintenance keep their existing plan shape. Async indexes remain CDC-only. ### Risk assessment - Normal UPDATEs do not enter the changed branch. - Synchronous IVF/full-text UPDATEs execute the same lock operation earlier in the same transaction; uncontended lock work and lock cardinality are unchanged. - Lock failure/cancellation now happens before hidden-table maintenance starts, reducing partial-work exposure. - Existing embedded full-text coverage verifies blocking, cancellation, rollback, retry, and hidden-index consistency. ### Tests - Added a deterministic planner regression for both IVF and full-text asserting that the shared maintenance sink depends on the base-table lock. - Added a control asserting ordinary UPDATE keeps `LOCK_OP` directly at the DML input. - Verified the new invariant fails on unfixed main and passes with this PR. - `go build -mod=readonly ./pkg/sql/plan` - `go vet -mod=readonly ./pkg/sql/plan` - `go test -count=1 ./pkg/sql/plan` - `go test -race -count=1 ./pkg/sql/plan` - Focused planner regressions with `-race -count=100` - `TestIssue26341CancelAndRetryFulltextUpdate` embedded-cluster regression Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…26518) The modern UPDATE planner previously routed affected FULLTEXT and vector indexes back to the legacy planner because it could not maintain their hidden tables. This prevented the UPDATE planner migration from completing and made index behavior depend on planner fallback. This change keeps plugin-supported irregular indexes on the modern planner path: - classifies synchronous and asynchronous indexes through plugin metadata and update-column hooks; - materializes the final UPDATE row image once and shares it with the base-table mutation and synchronous hidden-index delete/insert plans; - keeps asynchronous indexes CDC-only; - rejects primary-key updates when a synchronous irregular index would otherwise retain hidden rows keyed by the old primary key; - covers indexed columns, included columns, implicit `ON UPDATE` columns, route selection, and legacy handling for algorithms not yet migrated to the plugin contract. Validation: - `make -j8` - `make static-check` - `.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 ./pkg/sql/plan` - `.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 ./pkg/sql/plan` - focused planner tests with `-race -count=100` - `vector_ivfflat_include_dml_sync.sql` (25/25) - `fulltext_update_pk.sql` (21/21) - `fulltext.sql` (255/255) - manual transaction commit/rollback checks for synchronous FULLTEXT maintenance Approved by: @heni02, @XuPeng-SH
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…n#27144) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27142 Related to matrixorigin#27124, matrixorigin#26925, and matrixorigin#26518. ## What this PR does / why we need it: ### Root cause matrixorigin#26518 moved synchronous IVF/full-text UPDATE maintenance to separate top-level steps that consume a shared materialized final-row image. The pre-existing base-table `LOCK_OP` remained downstream of that materialization in only the main `MULTI_UPDATE` consumer. The main consumer and hidden-index consumers could therefore acquire locks independently: ```text T1: base row -> waits for IVF entries row T2: IVF entries row -> waits for base row ``` Production logs after the false self-cycle fix in matrixorigin#26925 contain real cycles between two different transactions updating the same primary key. These are genuine wait edges, so changing deadlock detection would hide the symptom rather than repair the lock order. ### Fix For UPDATEs with synchronous irregular-index maintenance, move the existing base/regular-index `LOCK_OP` before the shared row-image `SINK`: ```text final row image -> existing LOCK_OP -> shared SINK -> base MULTI_UPDATE -> irregular delete maintenance -> irregular insert maintenance ``` Every downstream consumer now receives a row only after its base lock has been acquired. A second transaction updating the same primary key waits at that gate before it can acquire a hidden-table lock. This PR does not add locks or change lock modes, commit-time release, RPC formats, or lockservice behavior. UPDATEs without synchronous irregular maintenance keep their existing plan shape. Async indexes remain CDC-only. ### Risk assessment - Normal UPDATEs do not enter the changed branch. - Synchronous IVF/full-text UPDATEs execute the same lock operation earlier in the same transaction; uncontended lock work and lock cardinality are unchanged. - Lock failure/cancellation now happens before hidden-table maintenance starts, reducing partial-work exposure. - Existing embedded full-text coverage verifies blocking, cancellation, rollback, retry, and hidden-index consistency. ### Tests - Added a deterministic planner regression for both IVF and full-text asserting that the shared maintenance sink depends on the base-table lock. - Added a control asserting ordinary UPDATE keeps `LOCK_OP` directly at the DML input. - Verified the new invariant fails on unfixed main and passes with this PR. - `go build -mod=readonly ./pkg/sql/plan` - `go vet -mod=readonly ./pkg/sql/plan` - `go test -count=1 ./pkg/sql/plan` - `go test -race -count=1 ./pkg/sql/plan` - Focused planner regressions with `-race -count=100` - `TestIssue26341CancelAndRetryFulltextUpdate` embedded-cluster regression Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26341
What this PR does / why we need it:
The modern UPDATE planner previously routed affected FULLTEXT and vector indexes back to the legacy planner because it could not maintain their hidden tables. This prevented the UPDATE planner migration from completing and made index behavior depend on planner fallback.
This change keeps plugin-supported irregular indexes on the modern planner path:
ON UPDATEcolumns, route selection, and legacy handling for algorithms not yet migrated to the plugin contract.Validation:
make -j8make static-check.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 ./pkg/sql/plan.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 ./pkg/sql/plan-race -count=100vector_ivfflat_include_dml_sync.sql(25/25)fulltext_update_pk.sql(21/21)fulltext.sql(255/255)