Skip to content

test: stabilize user lock cleanup cap accounting - #26400

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26397
Jul 29, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26397

Conversation

@gouhongshen

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

What this PR does / why we need it:

TestActiveUserLevelLockOwnersBoundRetainedCloseCleanupGrowth verifies retained
cleanup admission accounting, but it started the asynchronous cleanup worker
while asserting transient global-map state. The worker could consume the entry
before the assertion.

The failed assertion also ran while holding userLevelLocks. Because
require.Len terminates the test goroutine, the mutex remained locked and the
deferred reset blocked until the package-wide ten-minute timeout.

This change:

  • keeps the retained cleanup worker stopped while this accounting-only test
    observes capacity invariants;
  • snapshots protected state under the mutex and performs every assertion after
    unlocking;
  • restores the worker state before leaving the test.

Production user-level-lock behavior is unchanged.

Validation:

  • focused test: -count=100
  • focused race test: -race -count=30
  • focused coverage test: -cover -count=100
  • full pkg/sql/plan/function test package

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

Deep-reviewed exact head e809af9. The accounting-only test now suppresses worker startup while inspecting transient retained state, snapshots every userLevelLocks invariant under the mutex, and performs fail-fast assertions only after unlocking. I checked all failure points: runUserLevelLockTest defers the generation-aware reset, the synthetic started-without-done state is handled safely, and no cleanup goroutine crosses into the next test generation. The focused test passes count=200, race x100, and coverage x100; the full function package and go vet pass, git diff --check is clean, the head merges cleanly with current main, and the latest CI checks are green. No blocking issue found.

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

mergify Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-29 13:57 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-29 14:13 UTC · at fd87977771d2d735bf6a1d0b19236185299f5cf0

This pull request spent 15 minutes 51 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 717a377 into matrixorigin:main Jul 29, 2026
24 of 25 checks passed
@mergify mergify Bot added dequeued and removed queued labels Jul 29, 2026
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
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26397

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

`TestActiveUserLevelLockOwnersBoundRetainedCloseCleanupGrowth` verifies
retained
cleanup admission accounting, but it started the asynchronous cleanup
worker
while asserting transient global-map state. The worker could consume the
entry
before the assertion.

The failed assertion also ran while holding `userLevelLocks`. Because
`require.Len` terminates the test goroutine, the mutex remained locked
and the
deferred reset blocked until the package-wide ten-minute timeout.

This change:

- keeps the retained cleanup worker stopped while this accounting-only
test
  observes capacity invariants;
- snapshots protected state under the mutex and performs every assertion
after
  unlocking;
- restores the worker state before leaving the test.

Production user-level-lock behavior is unchanged.

Validation:

- focused test: `-count=100`
- focused race test: `-race -count=30`
- focused coverage test: `-cover -count=100`
- full `pkg/sql/plan/function` test package

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26397

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

`TestActiveUserLevelLockOwnersBoundRetainedCloseCleanupGrowth` verifies
retained
cleanup admission accounting, but it started the asynchronous cleanup
worker
while asserting transient global-map state. The worker could consume the
entry
before the assertion.

The failed assertion also ran while holding `userLevelLocks`. Because
`require.Len` terminates the test goroutine, the mutex remained locked
and the
deferred reset blocked until the package-wide ten-minute timeout.

This change:

- keeps the retained cleanup worker stopped while this accounting-only
test
  observes capacity invariants;
- snapshots protected state under the mutex and performs every assertion
after
  unlocking;
- restores the worker state before leaving the test.

Production user-level-lock behavior is unchanged.

Validation:

- focused test: `-count=100`
- focused race test: `-race -count=30`
- focused coverage test: `-cover -count=100`
- full `pkg/sql/plan/function` test package

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26397

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

`TestActiveUserLevelLockOwnersBoundRetainedCloseCleanupGrowth` verifies
retained
cleanup admission accounting, but it started the asynchronous cleanup
worker
while asserting transient global-map state. The worker could consume the
entry
before the assertion.

The failed assertion also ran while holding `userLevelLocks`. Because
`require.Len` terminates the test goroutine, the mutex remained locked
and the
deferred reset blocked until the package-wide ten-minute timeout.

This change:

- keeps the retained cleanup worker stopped while this accounting-only
test
  observes capacity invariants;
- snapshots protected state under the mutex and performs every assertion
after
  unlocking;
- restores the worker state before leaving the test.

Production user-level-lock behavior is unchanged.

Validation:

- focused test: `-count=100`
- focused race test: `-race -count=30`
- focused coverage test: `-cover -count=100`
- full `pkg/sql/plan/function` test package

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

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 kind/test-ci size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: user-level lock retained cleanup cap test races worker and deadlocks on assertion

3 participants