Skip to content

perf(lockservice): avoid txn overview builds for active txn checks - #25509

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
aptend:perf-lockservice-txn-active-checks
Jul 7, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
aptend:perf-lockservice-txn-active-checks

Conversation

@aptend

@aptend aptend commented Jul 7, 2026

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:

Related to #25279

What this PR does / why we need it:

This PR reduces the cost of lockservice active transaction validation paths involved in remote validTxn checks.

  • Add a CheckActiveTxn lockservice RPC for point lookup by ServiceID and TxnID.
  • Keep GetActiveTxn as the full active txn ID listing API for existing list consumers.
  • Use CheckActiveTxn in remote validTxn, with fallback to GetActiveTxn when the peer does not support the new method.
  • Add TxnClient.IterTxnIDs so lockservice TxnIterFunc can enumerate txn IDs without building TxnOverview or copying wait-lock state.
  • Keep callback execution outside internal txn-client locks.
  • Add focused coverage for IterTxnIDs and CheckActiveTxn handler behavior.

Validation:

go test -race -count=1 -timeout 180s ./pkg/txn/client
go test -count=1 -timeout 120s ./pkg/cnservice
go test -count=1 -timeout 120s -run 'TestHandleCheckActiveTxn|TestGetActiveTxnWithRemote|TestCannotCommit|TestValidTxn|TestCheckTxnTimeout' ./pkg/lockservice

@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

Choose a reason for hiding this comment

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

LGTM. The new CheckActiveTxn point-check path, old-peer fallback to GetActiveTxn, and the IterTxnIDs lock-avoidance path all look sound to me, and the targeted tests cover the important compatibility path.

@XuPeng-SH
XuPeng-SH merged commit dce1915 into matrixorigin:main Jul 7, 2026
23 checks passed
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…atrixorigin#25509)

## What type of PR is this?

- [x] API-change
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#25279

## What this PR does / why we need it:

This PR reduces the cost of lockservice active transaction validation
paths involved in remote `validTxn` checks.

- Add a `CheckActiveTxn` lockservice RPC for point lookup by `ServiceID`
and `TxnID`.
- Keep `GetActiveTxn` as the full active txn ID listing API for existing
list consumers.
- Use `CheckActiveTxn` in remote `validTxn`, with fallback to
`GetActiveTxn` when the peer does not support the new method.
- Add `TxnClient.IterTxnIDs` so lockservice `TxnIterFunc` can enumerate
txn IDs without building `TxnOverview` or copying wait-lock state.
- Keep callback execution outside internal txn-client locks.
- Add focused coverage for `IterTxnIDs` and `CheckActiveTxn` handler
behavior.

Validation:

```sh
go test -race -count=1 -timeout 180s ./pkg/txn/client
go test -count=1 -timeout 120s ./pkg/cnservice
go test -count=1 -timeout 120s -run 'TestHandleCheckActiveTxn|TestGetActiveTxnWithRemote|TestCannotCommit|TestValidTxn|TestCheckTxnTimeout' ./pkg/lockservice
```

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…atrixorigin#25509)

## What type of PR is this?

- [x] API-change
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#25279

## What this PR does / why we need it:

This PR reduces the cost of lockservice active transaction validation
paths involved in remote `validTxn` checks.

- Add a `CheckActiveTxn` lockservice RPC for point lookup by `ServiceID`
and `TxnID`.
- Keep `GetActiveTxn` as the full active txn ID listing API for existing
list consumers.
- Use `CheckActiveTxn` in remote `validTxn`, with fallback to
`GetActiveTxn` when the peer does not support the new method.
- Add `TxnClient.IterTxnIDs` so lockservice `TxnIterFunc` can enumerate
txn IDs without building `TxnOverview` or copying wait-lock state.
- Keep callback execution outside internal txn-client locks.
- Add focused coverage for `IterTxnIDs` and `CheckActiveTxn` handler
behavior.

Validation:

```sh
go test -race -count=1 -timeout 180s ./pkg/txn/client
go test -count=1 -timeout 120s ./pkg/cnservice
go test -count=1 -timeout 120s -run 'TestHandleCheckActiveTxn|TestGetActiveTxnWithRemote|TestCannotCommit|TestValidTxn|TestCheckTxnTimeout' ./pkg/lockservice
```

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…atrixorigin#25509)

## What type of PR is this?

- [x] API-change
- [ ] BUG
- [x] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related to matrixorigin#25279

## What this PR does / why we need it:

This PR reduces the cost of lockservice active transaction validation
paths involved in remote `validTxn` checks.

- Add a `CheckActiveTxn` lockservice RPC for point lookup by `ServiceID`
and `TxnID`.
- Keep `GetActiveTxn` as the full active txn ID listing API for existing
list consumers.
- Use `CheckActiveTxn` in remote `validTxn`, with fallback to
`GetActiveTxn` when the peer does not support the new method.
- Add `TxnClient.IterTxnIDs` so lockservice `TxnIterFunc` can enumerate
txn IDs without building `TxnOverview` or copying wait-lock state.
- Keep callback execution outside internal txn-client locks.
- Add focused coverage for `IterTxnIDs` and `CheckActiveTxn` handler
behavior.

Validation:

```sh
go test -race -count=1 -timeout 180s ./pkg/txn/client
go test -count=1 -timeout 120s ./pkg/cnservice
go test -count=1 -timeout 120s -run 'TestHandleCheckActiveTxn|TestGetActiveTxnWithRemote|TestCannotCommit|TestValidTxn|TestCheckTxnTimeout' ./pkg/lockservice
```

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>

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/api-change kind/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants