Repository navigation
fix(lockservice): treat active txn check errors as indeterminate - #25781
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.
Re-reviewed the latest head 3dad5174b1 from the first-principles / unhappy-path angle. The core contract change is the right one: checkRemoteActiveTxn now keeps a strict three-state meaning where transport or backend-reset failures stay unknown, so mapBasedTxnHolder.isValidRemoteTxn no longer installs a TN CannotCommit fence from an indeterminate MORPC observation. That closes the safety bug behind #25779 without regressing the cleanup chain: authoritative inactive results still go through the existing allocator/TN fence confirmation before unlock, and genuinely dead remote services are still reclaimed by the independent heartbeat-timeout path in getTimeoutRemoveTxn / unlockTimeoutRemoteTxn. Preserving the original reset error also improves observability without changing that safety contract.
I reran GOFLAGS=-mod=mod go test ./pkg/lockservice -count=1, the targeted error/concurrency race matrix for the new liveness cases, and GOFLAGS=-mod=mod go test ./pkg/txn/service -count=1 with the repo CGO env. I do not see a remaining correctness, robustness, or Q1/Q2/Q3 blocker on this head. GitHub still will not let me approve my own pull request, so I am leaving this as an approve-level review comment instead of an approval.
aptend
left a comment
There was a problem hiding this comment.
Reviewed head 58e4b29. The three-state liveness contract is correct: active results are retained, authoritative inactive results still require TN fence confirmation, and every active-check/reset error remains indeterminate without sending CannotCommit. This directly breaks the BackendClosed → false orphan classification → 20705 failure chain in #25779, while dead-CN cleanup remains covered by the independent remote-bind heartbeat timeout path. I also verified the full lockservice suite, targeted race/error cases, txn/service tests, build, vet, and Q1–Q3 unhappy paths. No blocking correctness, concurrency, resource-lifecycle, or compatibility issues found.
…rixorigin#25781) ## 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#25779 ## What this PR does / why we need it: An RPC failure while checking a remote active transaction is an indeterminate observation, not evidence that the transaction is inactive. The previous code classified some transport errors, including `BackendClosed` and `BackendCannotConnect`, as definitive enough to call `CannotCommit`. A transient MORPC failure could therefore install an irreversible TN fence for a healthy transaction and later fail its commit with error 20705. This PR establishes one uniform contract for remote transaction liveness: - `true, nil` means authoritatively active; - `false, nil` means authoritatively inactive and still requires TN fence confirmation before unlock; - any error means unknown, so the lock holder is retained and no `CannotCommit` request is sent. The periodic waiter check retries indeterminate observations. A genuinely dead CN is still reclaimed by the independent remote-bind heartbeat timeout path, which combines an expired heartbeat, service validation, and an allocator fence. Unknown-commit recovery and incarnation replacement keep their existing sequence/expiry/fence guarantees. The normal success path adds no RPC or synchronization. The error path avoids an unnecessary TN `CannotCommit` RPC. Reset errors are preserved instead of being converted to an internal error, improving diagnostics, and indeterminate checks are counted by the existing recovery metric. The tests cover local and active fast paths and their side effects, closed/unreachable/deadline/unclassified errors, retry followed by authoritative inactivity, and concurrent failed observations that must never fence. ### Verification - Full `pkg/lockservice` test suite, `-count=1`: PASS - Targeted liveness/error matrix, `-count=20`: PASS - Targeted concurrency tests with `-race`: PASS - `go build ./pkg/lockservice`: PASS - `go vet ./pkg/lockservice`: PASS - Dependent `pkg/txn/service` orphan and lock-table commit tests: PASS
…rixorigin#25781) ## 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#25779 ## What this PR does / why we need it: An RPC failure while checking a remote active transaction is an indeterminate observation, not evidence that the transaction is inactive. The previous code classified some transport errors, including `BackendClosed` and `BackendCannotConnect`, as definitive enough to call `CannotCommit`. A transient MORPC failure could therefore install an irreversible TN fence for a healthy transaction and later fail its commit with error 20705. This PR establishes one uniform contract for remote transaction liveness: - `true, nil` means authoritatively active; - `false, nil` means authoritatively inactive and still requires TN fence confirmation before unlock; - any error means unknown, so the lock holder is retained and no `CannotCommit` request is sent. The periodic waiter check retries indeterminate observations. A genuinely dead CN is still reclaimed by the independent remote-bind heartbeat timeout path, which combines an expired heartbeat, service validation, and an allocator fence. Unknown-commit recovery and incarnation replacement keep their existing sequence/expiry/fence guarantees. The normal success path adds no RPC or synchronization. The error path avoids an unnecessary TN `CannotCommit` RPC. Reset errors are preserved instead of being converted to an internal error, improving diagnostics, and indeterminate checks are counted by the existing recovery metric. The tests cover local and active fast paths and their side effects, closed/unreachable/deadline/unclassified errors, retry followed by authoritative inactivity, and concurrent failed observations that must never fence. ### Verification - Full `pkg/lockservice` test suite, `-count=1`: PASS - Targeted liveness/error matrix, `-count=20`: PASS - Targeted concurrency tests with `-race`: PASS - `go build ./pkg/lockservice`: PASS - `go vet ./pkg/lockservice`: PASS - Dependent `pkg/txn/service` orphan and lock-table commit tests: PASS
…rixorigin#25781) ## 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#25779 ## What this PR does / why we need it: An RPC failure while checking a remote active transaction is an indeterminate observation, not evidence that the transaction is inactive. The previous code classified some transport errors, including `BackendClosed` and `BackendCannotConnect`, as definitive enough to call `CannotCommit`. A transient MORPC failure could therefore install an irreversible TN fence for a healthy transaction and later fail its commit with error 20705. This PR establishes one uniform contract for remote transaction liveness: - `true, nil` means authoritatively active; - `false, nil` means authoritatively inactive and still requires TN fence confirmation before unlock; - any error means unknown, so the lock holder is retained and no `CannotCommit` request is sent. The periodic waiter check retries indeterminate observations. A genuinely dead CN is still reclaimed by the independent remote-bind heartbeat timeout path, which combines an expired heartbeat, service validation, and an allocator fence. Unknown-commit recovery and incarnation replacement keep their existing sequence/expiry/fence guarantees. The normal success path adds no RPC or synchronization. The error path avoids an unnecessary TN `CannotCommit` RPC. Reset errors are preserved instead of being converted to an internal error, improving diagnostics, and indeterminate checks are counted by the existing recovery metric. The tests cover local and active fast paths and their side effects, closed/unreachable/deadline/unclassified errors, retry followed by authoritative inactivity, and concurrent failed observations that must never fence. ### Verification - Full `pkg/lockservice` test suite, `-count=1`: PASS - Targeted liveness/error matrix, `-count=20`: PASS - Targeted concurrency tests with `-race`: PASS - `go build ./pkg/lockservice`: PASS - `go vet ./pkg/lockservice`: PASS - Dependent `pkg/txn/service` orphan and lock-table commit tests: PASS
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #25779
What this PR does / why we need it:
An RPC failure while checking a remote active transaction is an indeterminate observation, not evidence that the transaction is inactive. The previous code classified some transport errors, including
BackendClosedandBackendCannotConnect, as definitive enough to callCannotCommit. A transient MORPC failure could therefore install an irreversible TN fence for a healthy transaction and later fail its commit with error 20705.This PR establishes one uniform contract for remote transaction liveness:
true, nilmeans authoritatively active;false, nilmeans authoritatively inactive and still requires TN fence confirmation before unlock;CannotCommitrequest is sent.The periodic waiter check retries indeterminate observations. A genuinely dead CN is still reclaimed by the independent remote-bind heartbeat timeout path, which combines an expired heartbeat, service validation, and an allocator fence. Unknown-commit recovery and incarnation replacement keep their existing sequence/expiry/fence guarantees.
The normal success path adds no RPC or synchronization. The error path avoids an unnecessary TN
CannotCommitRPC. Reset errors are preserved instead of being converted to an internal error, improving diagnostics, and indeterminate checks are counted by the existing recovery metric.The tests cover local and active fast paths and their side effects, closed/unreachable/deadline/unclassified errors, retry followed by authoritative inactivity, and concurrent failed observations that must never fence.
Verification
pkg/lockservicetest suite,-count=1: PASS-count=20: PASS-race: PASSgo build ./pkg/lockservice: PASSgo vet ./pkg/lockservice: PASSpkg/txn/serviceorphan and lock-table commit tests: PASS