Repository navigation
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? |
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed e88f5e4 against main 3c7392a. No P0-P3 findings.
Verified that cleanup-only remote lock records remain available for unlock, are excluded from wait-for traversal, promote on a confirmed result without later downgrade, and are removed on lock/table cleanup and transaction reuse. Focused race stress (-count=100 for each affected regression) and one full go test -race -count=1 -timeout 240s ./pkg/lockservice passed locally; all PR checks are complete.
|
Queued — the merge queue status continues in this comment ↓. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed exact head e88f5e4. The cleanup-only/confirmed lock state transitions are closed across promotion, non-downgrade, lock removal, retryable table cleanup, transaction reset, and deadlock-graph snapshots. Conservative remote unlock behavior is preserved while uncertain rows no longer create false holder edges. The full lockservice package and focused race tests pass locally; no blocking finding.
Merge Queue Status
This pull request spent 25 minutes 48 seconds in the queue, with no time running CI. ReasonPull request #26925 has been merged manually at 50b32a1 HintYou were too fast! Tick the box to put this pull request back in the merge queue (same as
|
…27129) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #27124. Backport of #26925, which fixes #26922. ## What this PR does / why we need it: ### Root cause When a remote Lock response is lost, canceled, or times out, the source CN must retain the requested rows so transaction close can conservatively send Unlock. In 4.2-dev those cleanup records are stored in `activeTxn.tableKeys`, and distributed deadlock detection also treats every entry in that collection as proof that the transaction holds the row. If the request is still waiting on the owner, the owner returns that same transaction as a waiter and the polluted wait-for graph produces a false `T <= T` self-cycle. This exact sequence is present in #27124: a failed remote lock with `context canceled` is followed by a self-cycle and user-visible `20701`. ### Fix - Keep uncertain rows in `tableKeys` so conservative remote cleanup remains unchanged. - Track cleanup-only rows in a sparse per-table set and exclude them from `fetchWhoWaitingMe`. - Promote an uncertain row after a successful Lock result. - Never downgrade an already confirmed row after a later uncertain retry. - Remove sparse state on lock removal, table cleanup, transaction close, and object reuse. This does not suppress genuine multi-transaction deadlocks. It removes only deadlock edges that are not backed by a confirmed lock. Normal successful Lock calls do not allocate the sparse state. ### Validation - `TestRemoteWaitingListRequiresConfirmedHolder`: passed; race `-count=100` passed. - `TestCleanupOnlyLockStateTransitions`: passed; race `-count=100` passed. - `TestLockRemoteWithContextTimeoutTracksLockForUnlock`: passed; race `-count=100` passed. - `go build ./pkg/lockservice`: passed. - `go vet ./pkg/lockservice`: passed. - `go test ./pkg/lockservice`: passed. - `go test -race ./pkg/lockservice`: passed. Cherry-picked from `e88f5e4a706f28590f6dd69076cd38981eceaaa9`. Co-authored-by: XuPeng-SH <[email protected]>
## 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>
## 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.
…origin#26925) ## 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#26922 Related to matrixorigin#26888 and matrixorigin#26903. ## What this PR does / why we need it: ### Root cause When a remote Lock response is lost or times out, the source CN records the requested rows in `activeTxn.tableKeys` so transaction close can conservatively send Unlock. The same collection is also consumed by distributed deadlock detection as proof that the transaction holds each row. If the request is still waiting on the owner, that cleanup-only record makes the owner return the same transaction as its own waiter and produces a false `T <= T` cycle. This exactly matches the three transaction-correlated self-cycles observed in matrixorigin#26888. ### Fix - Keep uncertain rows in `tableKeys`, preserving conservative cleanup and preventing remote lock leaks. - Track only cleanup-only rows in a sparse per-table set and exclude them from `fetchWhoWaitingMe`. - Promote an uncertain row when a later Lock result confirms acquisition. - Never downgrade an already confirmed row when a later retry has an uncertain result. - Remove sparse state on lock removal, table cleanup, transaction close, and object reuse. No RPC/wire format changes are required. Normal successful Lock calls do not allocate the sparse state. Proxy-confirmed shared holders keep the existing deadlock-graph behavior. ### State transitions | Current state | Event | Next state | Cleanup | Deadlock graph | | --- | --- | --- | --- | --- | | absent | remote response uncertain | uncertain | included | excluded | | uncertain | successful Lock result | confirmed | included | included | | confirmed | remote response uncertain | confirmed | included | included | | either | lock/transaction cleanup | absent | removed | removed | ### Tests - Added a deterministic two-service regression reproducing the false self-edge while preserving a real confirmed remote-holder edge. - Added transition coverage for uncertain, promoted, non-downgraded, and removed rows. - Extended the existing remote timeout cleanup test to assert cleanup-only state. - Focused tests: `-count=100` passed. - Each focused test under race: `-count=100` passed. - `go test ./pkg/lockservice` passed. - `go test -race ./pkg/lockservice` passed. - `go vet ./pkg/lockservice` passed. No 4.2 backport is planned for this PR. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…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>
…origin#26925) ## 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#26922 Related to matrixorigin#26888 and matrixorigin#26903. ## What this PR does / why we need it: ### Root cause When a remote Lock response is lost or times out, the source CN records the requested rows in `activeTxn.tableKeys` so transaction close can conservatively send Unlock. The same collection is also consumed by distributed deadlock detection as proof that the transaction holds each row. If the request is still waiting on the owner, that cleanup-only record makes the owner return the same transaction as its own waiter and produces a false `T <= T` cycle. This exactly matches the three transaction-correlated self-cycles observed in matrixorigin#26888. ### Fix - Keep uncertain rows in `tableKeys`, preserving conservative cleanup and preventing remote lock leaks. - Track only cleanup-only rows in a sparse per-table set and exclude them from `fetchWhoWaitingMe`. - Promote an uncertain row when a later Lock result confirms acquisition. - Never downgrade an already confirmed row when a later retry has an uncertain result. - Remove sparse state on lock removal, table cleanup, transaction close, and object reuse. No RPC/wire format changes are required. Normal successful Lock calls do not allocate the sparse state. Proxy-confirmed shared holders keep the existing deadlock-graph behavior. ### State transitions | Current state | Event | Next state | Cleanup | Deadlock graph | | --- | --- | --- | --- | --- | | absent | remote response uncertain | uncertain | included | excluded | | uncertain | successful Lock result | confirmed | included | included | | confirmed | remote response uncertain | confirmed | included | included | | either | lock/transaction cleanup | absent | removed | removed | ### Tests - Added a deterministic two-service regression reproducing the false self-edge while preserving a real confirmed remote-holder edge. - Added transition coverage for uncertain, promoted, non-downgraded, and removed rows. - Extended the existing remote timeout cleanup test to assert cleanup-only state. - Focused tests: `-count=100` passed. - Each focused test under race: `-count=100` passed. - `go test ./pkg/lockservice` passed. - `go test -race ./pkg/lockservice` passed. - `go vet ./pkg/lockservice` passed. No 4.2 backport is planned for this PR. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…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>
…origin#26925) ## 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#26922 Related to matrixorigin#26888 and matrixorigin#26903. ## What this PR does / why we need it: ### Root cause When a remote Lock response is lost or times out, the source CN records the requested rows in `activeTxn.tableKeys` so transaction close can conservatively send Unlock. The same collection is also consumed by distributed deadlock detection as proof that the transaction holds each row. If the request is still waiting on the owner, that cleanup-only record makes the owner return the same transaction as its own waiter and produces a false `T <= T` cycle. This exactly matches the three transaction-correlated self-cycles observed in matrixorigin#26888. ### Fix - Keep uncertain rows in `tableKeys`, preserving conservative cleanup and preventing remote lock leaks. - Track only cleanup-only rows in a sparse per-table set and exclude them from `fetchWhoWaitingMe`. - Promote an uncertain row when a later Lock result confirms acquisition. - Never downgrade an already confirmed row when a later retry has an uncertain result. - Remove sparse state on lock removal, table cleanup, transaction close, and object reuse. No RPC/wire format changes are required. Normal successful Lock calls do not allocate the sparse state. Proxy-confirmed shared holders keep the existing deadlock-graph behavior. ### State transitions | Current state | Event | Next state | Cleanup | Deadlock graph | | --- | --- | --- | --- | --- | | absent | remote response uncertain | uncertain | included | excluded | | uncertain | successful Lock result | confirmed | included | included | | confirmed | remote response uncertain | confirmed | included | included | | either | lock/transaction cleanup | absent | removed | removed | ### Tests - Added a deterministic two-service regression reproducing the false self-edge while preserving a real confirmed remote-holder edge. - Added transition coverage for uncertain, promoted, non-downgraded, and removed rows. - Extended the existing remote timeout cleanup test to assert cleanup-only state. - Focused tests: `-count=100` passed. - Each focused test under race: `-count=100` passed. - `go test ./pkg/lockservice` passed. - `go test -race ./pkg/lockservice` passed. - `go vet ./pkg/lockservice` passed. No 4.2 backport is planned for this PR. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…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>
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #26922
Related to #26888 and #26903.
What this PR does / why we need it:
Root cause
When a remote Lock response is lost or times out, the source CN records the requested rows in
activeTxn.tableKeysso transaction close can conservatively send Unlock. The same collection is also consumed by distributed deadlock detection as proof that the transaction holds each row.If the request is still waiting on the owner, that cleanup-only record makes the owner return the same transaction as its own waiter and produces a false
T <= Tcycle. This exactly matches the three transaction-correlated self-cycles observed in #26888.Fix
tableKeys, preserving conservative cleanup and preventing remote lock leaks.fetchWhoWaitingMe.No RPC/wire format changes are required. Normal successful Lock calls do not allocate the sparse state. Proxy-confirmed shared holders keep the existing deadlock-graph behavior.
State transitions
Tests
-count=100passed.-count=100passed.go test ./pkg/lockservicepassed.go test -race ./pkg/lockservicepassed.go vet ./pkg/lockservicepassed.No 4.2 backport is planned for this PR.