Skip to content

fix ut - #25792

Merged
XuPeng-SH merged 9 commits into
matrixorigin:mainfrom
daviszhen:0715-fix-ut
Jul 17, 2026
Merged

fix ut#25792
XuPeng-SH merged 9 commits into
matrixorigin:mainfrom
daviszhen:0715-fix-ut

Conversation

@daviszhen

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:

issue #25735

#25734

#25729

What this PR does / why we need it:

  • 修复同步 lock waiter 返回后仍被 waiterEvents 持有的问题,及时移除并释放 events 引用,避免 waiter 复用时发生 data race。
  • waiterEvents.close() 清空 waiter 列表,防止关闭后重复释放引用。
  • 增加 waiter 生命周期、关闭和 range-lock 并发回归测试。
  • 修正 QueryService 并发 UT:预热 MORPC backend,消除首次建连竞争导致的偶现失败。
  • 删除 Dispatch UT 中不成立的异步时序断言,保留能够直接证明 receiver 已注册的断言。
  • UT 使用非池化 waiter,避免污染全局 reuse checker。

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

@mergify mergify Bot added the kind/bug Something isn't working label Jul 16, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Jul 16, 2026
@daviszhen

Copy link
Copy Markdown
Contributor Author

Double-check found one blocking test regression; the lockservice waiter fix itself remains sound.

The PR base already contains cfca2ec32 fix(morpc): wake waiters when backend creation completes (#25771), which fixed the cold-start backend-creation wakeup race reported by #25734. I restored the original no-warmup scenario on this head and ran it with -race -count=100; all runs passed. Therefore the warmup is not needed for stability on the current base. It removes coverage of the exact cold concurrent backend-creation path that #25771 fixed and changes this test into the materially weaker case of concurrent sends after a backend already exists.

Please keep the requests cold so this remains a regression test for #25734/#25771. Removing the callback mutex and scheduling sleep is fine because RequestMultipleCn invokes response handlers serially.

已经修改.

  • 修复 lockservice 同步 waiter 复用时与后台检查的 data race,等待结束后及时移出事件列表并释放引用。
  • 修正 dispatch UT 中错误的时序断言,避免偶现失败。
  • 恢复 queryservice 冷启动并发测试,覆盖 MORPC backend 首次创建及 waiter 唤醒,删除无必要的 mutex 和 sleep。
  • 补充 waiter 生命周期、引用释放和关闭清理 UT。

@daviszhen
daviszhen requested review from XuPeng-SH and fengttt July 17, 2026 06:07

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

Re-reviewed current head e0613dc after the cold-start QueryService regression was restored. The previous blocker is resolved.

The lockservice ownership closure is sound: waiterEvents takes one reference per blocked-list entry; checker removal, synchronous removal, and service close are serialized by the same mutex, so each events-owned reference is released exactly once. The synchronous path now removes that old-generation reference after wait completion and before reset/requeue, preventing the checker from observing a reused waiter. Lock-queue, active-transaction, events, and caller references remain independent and symmetric across success, timeout/cancellation, range-lock requeue, and close. Clearing the slice also drops stale backing-array references.

The QueryService test again keeps the backend cold and therefore covers concurrent backend creation and waiter wakeup. Response handlers are invoked serially by the draining loop, so removing the test mutex and sleep is valid. The Dispatch assertion that was removed depended on sender scheduling after an unbuffered-channel handoff; the retained remoteReceivers assertion directly proves registration.

Validation on the clean synthetic merge with current main: focused race tests passed for lockservice x20, cold QueryService x50, and Dispatch x50. Full owning-package race suites also passed for lockservice, queryservice, and dispatch. CI is green and the PR merges cleanly. No blocking findings.

@mergify mergify Bot added the queued label Jul 17, 2026
@mergify

mergify Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-17 06:35 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-17 07:56 UTC · at 46ca5ed27fdecc46b86d3f5a0173692e6a595a92

This pull request spent 1 hour 20 minutes 32 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

This pull request seems to come from a fork, and Mergify needs the author's permission to update its branch.
The author needs to enable "Allow edits from maintainers" on this pull request, or update the branch manually.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit c184363 into matrixorigin:main Jul 17, 2026
23 of 24 checks passed
@mergify mergify Bot added dequeued and removed queued labels Jul 17, 2026
XuPeng-SH added a commit that referenced this pull request Jul 17, 2026
…1-dev (#25849)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Backport of #25447 to 4.1-dev.

Fixes #25297
Fixes #25278
Related to #25279

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

Backports the lockservice fix for owner-local remote lock deadlocks:

- detects owner-local wait cycles rooted at the actual conflicting
holders;
- caps owner-side remote lock waits at two minutes by default;
- retains remote lock metadata so rollback can release partially granted
locks;
- fixes deadlock detector enqueue bookkeeping and adds focused metrics;
- removes completed synchronous waiters from the deadlock-event set
before a waiter can be reused, and drops retained waiter references
during shutdown (the relevant lockservice portion of #25792).

Method_Lock is still protocol v1 and has no peer capability signal. The
owner therefore keeps the dedicated ErrRemoteLockWaitTimeout internally
but sends the existing ErrDeadLockDetected over v1. Every supported 4.1
origin recognizes that code as a whole-transaction rollback, so it
issues remote unlock even for a partial multi-row grant during a rolling
upgrade.

The cherry-pick applies cleanly to the current 4.1-dev / v4.1.2
baseline. Follow-up #25469 remains unnecessary on this branch: 4.1
already releases the forwarded transaction lock with defer txn.Unlock()
before entering the asynchronous wait path.

## Validation

- go test -v ./pkg/lockservice -count=1 -timeout=20m — PASS (573.999s)
- go build ./pkg/lockservice — PASS
- go vet ./pkg/lockservice — PASS
- focused waiter and V1 compatibility regression tests under -race
-count=10 — PASS
- go test ./pkg/frontend -run Test_isErrorRollbackWholeTxn -count=1
-timeout=5m (with repository CGO/rpath settings) — PASS

The V1 compatibility test makes a two-row remote request acquire row 1
then time out on row 2, checks the legacy deadlock code, performs the
old-origin whole-transaction unlock, and verifies row 1 is immediately
lockable.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 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:

issue matrixorigin#25735

matrixorigin#25734

matrixorigin#25729

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

- 修复同步 lock waiter 返回后仍被 waiterEvents 持有的问题,及时移除并释放 events 引用,避免 waiter
复用时发生 data race。
  - waiterEvents.close() 清空 waiter 列表,防止关闭后重复释放引用。
  - 增加 waiter 生命周期、关闭和 range-lock 并发回归测试。
  - 修正 QueryService 并发 UT:预热 MORPC backend,消除首次建连竞争导致的偶现失败。
  - 删除 Dispatch UT 中不成立的异步时序断言,保留能够直接证明 receiver 已注册的断言。
  - UT 使用非池化 waiter,避免污染全局 reuse checker。

---------

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
## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#25735

matrixorigin#25734

matrixorigin#25729

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

- 修复同步 lock waiter 返回后仍被 waiterEvents 持有的问题,及时移除并释放 events 引用,避免 waiter
复用时发生 data race。
  - waiterEvents.close() 清空 waiter 列表,防止关闭后重复释放引用。
  - 增加 waiter 生命周期、关闭和 range-lock 并发回归测试。
  - 修正 QueryService 并发 UT:预热 MORPC backend,消除首次建连竞争导致的偶现失败。
  - 删除 Dispatch UT 中不成立的异步时序断言,保留能够直接证明 receiver 已注册的断言。
  - UT 使用非池化 waiter,避免污染全局 reuse checker。

---------

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
## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#25735

matrixorigin#25734

matrixorigin#25729

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

- 修复同步 lock waiter 返回后仍被 waiterEvents 持有的问题,及时移除并释放 events 引用,避免 waiter
复用时发生 data race。
  - waiterEvents.close() 清空 waiter 列表,防止关闭后重复释放引用。
  - 增加 waiter 生命周期、关闭和 range-lock 并发回归测试。
  - 修正 QueryService 并发 UT:预热 MORPC backend,消除首次建连竞争导致的偶现失败。
  - 删除 Dispatch UT 中不成立的异步时序断言,保留能够直接证明 receiver 已注册的断言。
  - UT 使用非池化 waiter,避免污染全局 reuse checker。

---------

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

5 participants