Skip to content

fix(lockservice): treat active txn check errors as indeterminate - #25781

Merged
XuPeng-SH merged 4 commits into
mainfrom
fix/lockservice-active-txn-transport-unknown
Jul 15, 2026
Merged

XuPeng-SH merged 4 commits into
mainfrom
fix/lockservice-active-txn-transport-unknown

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

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

@XuPeng-SH
XuPeng-SH requested a review from iamlinjunhong as a code owner July 15, 2026 12:10
@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.

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.

@XuPeng-SH
XuPeng-SH requested a review from aptend July 15, 2026 12:22

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@XuPeng-SH
XuPeng-SH merged commit 0d8111a into main Jul 15, 2026
22 of 25 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix/lockservice-active-txn-transport-unknown branch July 15, 2026 14:52
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…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

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

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: merge-trigger-tke TPCC repeatedly fails after inter-CN MORPC backend closes and transactions are marked orphan

3 participants