Skip to content

test: reuse UT fixtures and observe SQL task scheduler cleanup - #28613

Merged
XuPeng-SH merged 2 commits into
mainfrom
codex/ut-fixture-reuse-next
Sep 10, 2026
Merged

XuPeng-SH merged 2 commits into
mainfrom
codex/ut-fixture-reuse-next

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • Improvement
  • Test and CI

Which issue(s) this PR fixes:

#28419
Follow-up to #28568 and #28607; no separate issue.

What this PR does / why we need it:

Repeated setup and fixed sleeps add time to the embedded UT lane. Reuse compatible fixtures and wait for actual SQL-task scheduler cleanup:

  • Share one ordinary tenant between the concurrent branch-deletion and mo_subs update regressions. Keep their assertions and per-case data cleanup.
  • Create four immutable PICK sources instead of twelve. Keep all 12 shape/policy cases, independent destinations, and add full source-row immutability assertions after each policy.
  • Run the S3-disabled Arrow gate checks as a subtest in the identically configured rollback/drain fixture, avoiding one cluster startup. Keep rollout restarts and shutdown assertions.
  • Replace the SQL-task lifecycle test's fixed 12-second sleep with observed HAKeeper reconciliation and completed overdue catch-up executions. Assert the repeating task entered the scheduler cache before deletion. Preserve cross-CN execution/drop and durable residue checks.

The scheduler observer is inactive unless installed by a test. Unit tests cover snapshot ownership, deletion before reconciliation, and reconciliation finishing while an overdue execution remains blocked. Cluster admission and test data sizes are unchanged.

Validation

  • All affected integration tests passed locally with -race -count=3 -tags matrixone_test.
  • Both new scheduler observer tests passed with -race -count=3.
  • golangci-lint: 0 issues across the five affected packages; molint passed. Rechecked the isolated package after the final scheduler-owner correction.
  • License checks and git diff --check passed.
  • Independent GPT-6 medium review completed; fixed its finding that overdue stopper-managed executions must also drain, then re-reviewed.

CI wall-time savings require a CI run; local timings do not predict runner contention or the job critical path.

Local timing comparison

Same-machine -race -count=1 on base 269d59addd and this branch, selected packages run serially (-p=1). Baseline PICK and tenant cases encountered admission waits of 0.457s and 57.136s respectively; these waits are subtracted below, so they are not counted as optimization savings. Results are one sample, not a controlled CI benchmark.

Selected cases Base, excluding admission wait Updated
PICK 24.91s 23.03s
Two tenant regressions 23.56s 20.81s
Arrow rollout + S3 gate 38.23s 28.21s
SQL-task lifecycle 41.06s 31.30s

Total selected test time: 127.77s → 103.35s (about 24.4s / 19% lower locally). Compilation and package teardown are excluded. The unchanged admission policy still serializes live embedded clusters.

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

Reviewed head eebc942 against live main/merge-base 269d59a. COMMENT only for this self-authored PR. No concrete blocking findings.

Coverage/isolation:

  • Both tenant regressions remain named, serial subtests. They share ordinary-account setup, not SQL sessions or their data: per-case database/catalog cleanup and all original positive/negative assertions remain, with the parent owning account deletion.
  • PICK retains all four shapes × three policies and independent destinations. Sharing the source does not mask source mutation: complete ordered source rows are checked after every policy, in addition to the original destination/conflict oracles.
  • The S3-disabled case runs before rollout/shutdown under the identical cluster policy. Its configuration-error and zero-row assertions remain; its SQL pool closes at subtest cleanup before the rollout proceeds. Separate database names prevent interference.

Scheduler closure:

  • Observation is scoped to this cluster's HAKeeper/logservice owner, not CN execution caches. The test first proves the repeating task was cached, then requires a successful reconciliation to remove the tracked IDs.
  • removeSQLTask waits for cron.Stop().Done() before deleting the entry; the refresh snapshot is published after reconciliation. Overdue stopper-managed job.Run calls are separately bracketed before admission and through completion, including failed admission, so an empty cache cannot hide that in-flight producer.
  • Registration uses an atomic pointer; completion captures the original observer, avoiding mismatched start/finish events after restoration. Callback state is mutex/atomic protected, and the installing tests are serial. With no hook installed, the production path does not allocate snapshots or introduce a background worker.
  • The new deterministic UT holds an overdue execution across storage deletion/reconciliation and proves the active count remains nonzero until released. Its failure cleanup unblocks before stopping/joining the worker. The snapshot UT independently verifies ownership and that deleting storage alone is not reported as scheduler cleanup.

Q1: per-subtest sessions/data and parent fixtures retain cleanup owners; overdue observer completion is paired on normal/error exits.
Q2: the new wait is bounded observation of reconciliation plus producer completion, not a fixed scheduling sleep; the blocked UT has an independent cleanup release.
Q3: snapshots and counters are limited to the test fixture/task set; production nil-hook overhead is constant and no accumulating production state is added.

Design gate: bounded fixture maintenance and an observational test seam; no independent feature/major-refactor gate. The observer does not change scheduling policy or cleanup ownership.

Validation: inspected the full nine-file diff, current comments/review history, scheduler/stopper terminal paths and fixture helpers; git diff --check passed. The PR reports affected integration and observer tests passing with -race -count=3, plus lint, and gives same-machine baseline/current timings with admission waits separated. I did not independently rerun native/embedded tests or wait for CI; those timings do not establish CI critical-path savings. Head/base were rechecked unchanged before submission.

@XuPeng-SH
XuPeng-SH merged commit 9a07655 into main Sep 10, 2026
26 of 29 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/ut-fixture-reuse-next branch September 10, 2026 08:54
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…xorigin#28613)

## What type of PR is this?

- [x] Improvement
- [x] Test and CI

## Which issue(s) this PR fixes:

matrixorigin#28419
Follow-up to matrixorigin#28568 and matrixorigin#28607; no separate issue.

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

Repeated setup and fixed sleeps add time to the embedded UT lane. Reuse
compatible fixtures and wait for actual SQL-task scheduler cleanup:

- Share one ordinary tenant between the concurrent branch-deletion and
mo_subs update regressions. Keep their assertions and per-case data
cleanup.
- Create four immutable PICK sources instead of twelve. Keep all 12
shape/policy cases, independent destinations, and add full source-row
immutability assertions after each policy.
- Run the S3-disabled Arrow gate checks as a subtest in the identically
configured rollback/drain fixture, avoiding one cluster startup. Keep
rollout restarts and shutdown assertions.
- Replace the SQL-task lifecycle test's fixed 12-second sleep with
observed HAKeeper reconciliation and completed overdue catch-up
executions. Assert the repeating task entered the scheduler cache before
deletion. Preserve cross-CN execution/drop and durable residue checks.

The scheduler observer is inactive unless installed by a test. Unit
tests cover snapshot ownership, deletion before reconciliation, and
reconciliation finishing while an overdue execution remains blocked.
Cluster admission and test data sizes are unchanged.

### Validation

- All affected integration tests passed locally with `-race -count=3
-tags matrixone_test`.
- Both new scheduler observer tests passed with `-race -count=3`.
- golangci-lint: 0 issues across the five affected packages; molint
passed. Rechecked the isolated package after the final scheduler-owner
correction.
- License checks and `git diff --check` passed.
- Independent GPT-6 medium review completed; fixed its finding that
overdue stopper-managed executions must also drain, then re-reviewed.

CI wall-time savings require a CI run; local timings do not predict
runner contention or the job critical path.

### Local timing comparison

Same-machine `-race -count=1` on base `269d59addd` and this branch,
selected packages run serially (`-p=1`). Baseline PICK and tenant cases
encountered admission waits of 0.457s and 57.136s respectively; these
waits are subtracted below, so they are not counted as optimization
savings. Results are one sample, not a controlled CI benchmark.

| Selected cases | Base, excluding admission wait | Updated |
| --- | ---: | ---: |
| PICK | 24.91s | 23.03s |
| Two tenant regressions | 23.56s | 20.81s |
| Arrow rollout + S3 gate | 38.23s | 28.21s |
| SQL-task lifecycle | 41.06s | 31.30s |

Total selected test time: 127.77s → 103.35s (about 24.4s / 19% lower
locally). Compilation and package teardown are excluded. The unchanged
admission policy still serializes live embedded clusters.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…xorigin#28613)

## What type of PR is this?

- [x] Improvement
- [x] Test and CI

## Which issue(s) this PR fixes:

matrixorigin#28419
Follow-up to matrixorigin#28568 and matrixorigin#28607; no separate issue.

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

Repeated setup and fixed sleeps add time to the embedded UT lane. Reuse
compatible fixtures and wait for actual SQL-task scheduler cleanup:

- Share one ordinary tenant between the concurrent branch-deletion and
mo_subs update regressions. Keep their assertions and per-case data
cleanup.
- Create four immutable PICK sources instead of twelve. Keep all 12
shape/policy cases, independent destinations, and add full source-row
immutability assertions after each policy.
- Run the S3-disabled Arrow gate checks as a subtest in the identically
configured rollback/drain fixture, avoiding one cluster startup. Keep
rollout restarts and shutdown assertions.
- Replace the SQL-task lifecycle test's fixed 12-second sleep with
observed HAKeeper reconciliation and completed overdue catch-up
executions. Assert the repeating task entered the scheduler cache before
deletion. Preserve cross-CN execution/drop and durable residue checks.

The scheduler observer is inactive unless installed by a test. Unit
tests cover snapshot ownership, deletion before reconciliation, and
reconciliation finishing while an overdue execution remains blocked.
Cluster admission and test data sizes are unchanged.

### Validation

- All affected integration tests passed locally with `-race -count=3
-tags matrixone_test`.
- Both new scheduler observer tests passed with `-race -count=3`.
- golangci-lint: 0 issues across the five affected packages; molint
passed. Rechecked the isolated package after the final scheduler-owner
correction.
- License checks and `git diff --check` passed.
- Independent GPT-6 medium review completed; fixed its finding that
overdue stopper-managed executions must also drain, then re-reviewed.

CI wall-time savings require a CI run; local timings do not predict
runner contention or the job critical path.

### Local timing comparison

Same-machine `-race -count=1` on base `269d59addd` and this branch,
selected packages run serially (`-p=1`). Baseline PICK and tenant cases
encountered admission waits of 0.457s and 57.136s respectively; these
waits are subtracted below, so they are not counted as optimization
savings. Results are one sample, not a controlled CI benchmark.

| Selected cases | Base, excluding admission wait | Updated |
| --- | ---: | ---: |
| PICK | 24.91s | 23.03s |
| Two tenant regressions | 23.56s | 20.81s |
| Arrow rollout + S3 gate | 38.23s | 28.21s |
| SQL-task lifecycle | 41.06s | 31.30s |

Total selected test time: 127.77s → 103.35s (about 24.4s / 19% lower
locally). Compilation and package teardown are excluded. The unchanged
admission policy still serializes live embedded clusters.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…xorigin#28613)

## What type of PR is this?

- [x] Improvement
- [x] Test and CI

## Which issue(s) this PR fixes:

matrixorigin#28419
Follow-up to matrixorigin#28568 and matrixorigin#28607; no separate issue.

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

Repeated setup and fixed sleeps add time to the embedded UT lane. Reuse
compatible fixtures and wait for actual SQL-task scheduler cleanup:

- Share one ordinary tenant between the concurrent branch-deletion and
mo_subs update regressions. Keep their assertions and per-case data
cleanup.
- Create four immutable PICK sources instead of twelve. Keep all 12
shape/policy cases, independent destinations, and add full source-row
immutability assertions after each policy.
- Run the S3-disabled Arrow gate checks as a subtest in the identically
configured rollback/drain fixture, avoiding one cluster startup. Keep
rollout restarts and shutdown assertions.
- Replace the SQL-task lifecycle test's fixed 12-second sleep with
observed HAKeeper reconciliation and completed overdue catch-up
executions. Assert the repeating task entered the scheduler cache before
deletion. Preserve cross-CN execution/drop and durable residue checks.

The scheduler observer is inactive unless installed by a test. Unit
tests cover snapshot ownership, deletion before reconciliation, and
reconciliation finishing while an overdue execution remains blocked.
Cluster admission and test data sizes are unchanged.

### Validation

- All affected integration tests passed locally with `-race -count=3
-tags matrixone_test`.
- Both new scheduler observer tests passed with `-race -count=3`.
- golangci-lint: 0 issues across the five affected packages; molint
passed. Rechecked the isolated package after the final scheduler-owner
correction.
- License checks and `git diff --check` passed.
- Independent GPT-6 medium review completed; fixed its finding that
overdue stopper-managed executions must also drain, then re-reviewed.

CI wall-time savings require a CI run; local timings do not predict
runner contention or the job critical path.

### Local timing comparison

Same-machine `-race -count=1` on base `269d59addd` and this branch,
selected packages run serially (`-p=1`). Baseline PICK and tenant cases
encountered admission waits of 0.457s and 57.136s respectively; these
waits are subtracted below, so they are not counted as optimization
savings. Results are one sample, not a controlled CI benchmark.

| Selected cases | Base, excluding admission wait | Updated |
| --- | ---: | ---: |
| PICK | 24.91s | 23.03s |
| Two tenant regressions | 23.56s | 20.81s |
| Arrow rollout + S3 gate | 38.23s | 28.21s |
| SQL-task lifecycle | 41.06s | 31.30s |

Total selected test time: 127.77s → 103.35s (about 24.4s / 19% lower
locally). Compilation and package teardown are excluded. The unchanged
admission policy still serializes live embedded clusters.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants