Skip to content

test: serialize embedded cluster lifecycles across UT processes - #26667

Merged
mergify[bot] merged 7 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26522
Aug 4, 2026
Merged

mergify[bot] merged 7 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-26522

Conversation

@gouhongshen

@gouhongshen gouhongshen commented Aug 4, 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:

issue #26522

What this PR does / why we need it:

Root cause

The Ubuntu/x86 UT job runs package tests with UT_PARALLEL=6 on an 8-core/16-GB runner. Several test binaries can therefore keep independent LogService/TN/CN clusters alive concurrently. Under that load, delayed Dragonboat ticks and HAKeeper heartbeat/proposal timeouts can prevent TN shard readiness and produce downstream connection resets.

The previous startup lease serialized only cluster bootstrap. The first version of this PR serialized 12 complete packages, which removed overlapping cluster runtimes but added a roughly 14-minute serial CI phase. The shared base cluster also overrode the CN/TN heartbeat RPC deadline to 30 seconds, delaying the next heartbeat and schedule-command delivery when a request stalled.

Changes

  • add a reusable pkg/testutil/clusteradmission module backed by a runner-wide file lock;
  • make admission reentrant inside one test process, preserving tests that intentionally run multiple clusters together;
  • hold admission from cluster Start until all services have closed successfully;
  • retain admission after cleanup errors so another test process cannot overlap a partially running cluster;
  • release the OS lock automatically when a failed test process exits;
  • integrate admission in pkg/embed and pkg/tests/service; pkg/tests/txn inherits it through the service cluster;
  • restore the pre-PR package parallelism and resource classifications in optools/run_ut.sh instead of maintaining a separate 12-package serial list;
  • remove the shared base cluster heartbeat RPC timeout override while retaining the independent 60-second TN/CN store-liveness window;
  • update regression tests for admission reentrancy, cross-process exclusion, successful lifecycle, startup rollback, close retry, and heartbeat configuration.

This PR changes the test-cluster resource contract only. The production heartbeat/command-progress design remains tracked by #26566.

Validation

  • go test -race ./pkg/testutil/clusteradmission -count=1
  • focused race tests for embedded-cluster admission, startup rollback, and close retry;
  • focused race test for the service-cluster admission lifecycle;
  • all 12 complete-cluster packages together with -short -race -p 6;
  • the same 12 packages with -p 1 as a local timing control;
  • bash -n optools/run_ut.sh
  • make err-check
  • git diff --check

Local 12-package comparison on the same machine:

Mode Duration
lifecycle admission, -p 6 382.83s
package serial, -p 1 493.04s

The local comparison reduced elapsed time by 110.21 seconds (22%). The production Ubuntu/x86 job remains authoritative for both total CI duration and the original waitAnyShardReadyLocked, delayed LocalTick, heartbeat timeout, and connection-reset signatures.

@gouhongshen

gouhongshen commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Design change at e611a72766: validation samples 1-6 below exercised the previous package-serial implementation. They remain baseline evidence for #26522, but do not count as validation of the new process-lifecycle admission design. New-design validation starts with workflow run 30901937950.

Ubuntu/x86 UT repeated validation

  • Fix commit: e8fd93e5c1d495c984b6b9d816e36846d8dcfd92
  • Current PR head: f3ad72030978de355d49304180194b78ea9d8560 (latest merge from main; process-lifecycle admission changes remain in this head)
  • Target: 20 successful attempts on the production Ubuntu/x86 runner
  • Successful attempts: 5 / 20
  • Current: automation remains paused; sample 6 was manually triggered and succeeded
  • Policy: no automatic retry after a failure; inspect the root cause first
Sample Head Job Result Duration #26522 signatures
1 e8fd93e5c1 91880478396 Success 41m14s None; text matches were passing test names only
2 e8fd93e5c1 91890077629 Success 42m30s None; text matches were passing test names only
3 637674beb3 91897800175 Success 42m38s None; text matches were passing test names only
Infra 637674beb3 91909322957 Invalid sample 2m05s UT never started: actions/setup-java lost TLS connection
4 637674beb3 91912179642 Success 45m27s None; text matches were passing test names only
5 637674beb3 91921546183 Failed: unrelated ISCP UT 51m32s None; embedded-cluster scope passed
6 0cf0d6e7e2 91940828757 Success 44m04s None; waitAnyShardReadyLocked was a passing test name only

All six valid UT samples verified CLUSTER UT: 1 and Run embedded-cluster race-test packages serially; the embedded-cluster scope passed in every sample. Runtime occurrences of delayed LocalTick, connection reset by peer, and HAKeeper proposal/checker/heartbeat timeout signatures were zero. Sample 5 failed pkg/vm/engine/test.TestISCPExecutor6: ISCP attempted range 1785829151090554909-2 -> 1785829151090554909-0, logged invalid timestamp, and its watermark remained 0-0 past the 10-second assertion. The same test passed in samples 1-4 and the full UT passed again in sample 6. This failure is outside the PR diff and outside #26522.

Process-lifecycle admission validation

Sample Head Job Result Total Unit Testing Stage timing #26522 signatures
A1 e611a72766 91968178620 Success 34m42s 32m14s prep 3m03s; light p6 15m46s; exclusive p1 7m17s; heavy p3 4m29s; plan 1m38s None; all text matches were passing test names
A2 6ab8b1e95b 91993046677 Success 36m56s 34m11s setup 2m25s; prep 2m45s; light p6 16m19s; exclusive p1 8m05s; heavy p3 7m02s None; all text matches were passing test names
A3 f3ad720309 92027481669 In progress - - merge-main validation run Pending

The log contains CLUSTER ADMISSION: process lifecycle. Runtime occurrences of delayed LocalTick, connection reset by peer, and HAKeeper proposal/checker/heartbeat timeout were zero. waitAnyShardReadyLocked appeared once as the passing test Test_waitAnyShardReadyLocked; the two heartbeat-timeout matches were passing configuration tests.

The five successful package-serial baseline jobs averaged 43m11s. A1 completed 8m29s faster (19.6%), and 6m32s faster than the fastest old successful sample (41m14s). A1 and A2 both activated process-lifecycle admission and passed without #26522 runtime signatures. A2 completed in 36m56s (34m11s Unit Testing). A3 is the new merge-main validation run and is currently in progress.

@gouhongshen
gouhongshen marked this pull request as ready for review August 4, 2026 04:05
@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 →

@gouhongshen gouhongshen changed the title test(ci): serialize embedded cluster package tests test: serialize embedded cluster lifecycles across UT processes Aug 4, 2026
@mergify mergify Bot removed the dequeued label Aug 4, 2026
@mergify

mergify Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-04 15:25 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-08-04 15:26 UTC · at f3ad72030978de355d49304180194b78ea9d8560 · squash

This pull request spent 29 seconds in the queue, including 2 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

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

4 participants