Skip to content

test(morpc): synchronize client gc tests - #29674

Merged
XuPeng-SH merged 4 commits into
mainfrom
codex/quality-29249-morpc-20261007
Oct 8, 2026
Merged

XuPeng-SH merged 4 commits into
mainfrom
codex/quality-29249-morpc-20261007

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 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:

Refs #29249

What this PR does / why we need it:

Make the global morpc client-GC tests observe the actual backend state and cleanup completion instead of sleeping for fixed intervals.

  • Replace the async backend helper's ten 10 ms retries with require.Eventually over the same client.getBackend entrypoint and a bounded one-second deadline.
  • Remove sleeps around the synchronous doGCIdle owner and assert both pool detachment and the backend's eventual Close effect.
  • Replace inactive/create worker sleeps with exact terminal-state polling; wait for the exact create-state completion while the manager remains live, then assert zero factory calls and no backend for the unregistered client.
  • Remove an integration sleep with no assertion and assert closed-client create admission directly.
  • Register manager/client cleanup before fatal assertions and restore the synthetic closed state on all exit paths.
  • Retain the concurrency stress sleeps that intentionally perturb scheduling; they are not used as completion waits.

Only client_gc_test.go changes. No production code, GC ownership, worker scheduling, or cleanup path was changed.

Coverage and design mapping

Previous wait Deterministic contract retained
Backend helper retry/sleep loop Existing client.getBackend entrypoint reaches a non-nil backend or fails within a bounded assertion
Idle GC sleeps doGCIdle synchronously removes the idle slot and the owned backend eventually reports closed
Inactive/create worker sleeps The worker publishes the exact pool state (0 or 1)
Unregistered-client wait Exact admitted request completes while the manager is live; the existing factory counter and pool prove rejection
Integration-only idle wait Removed because it had no independent oracle
Closed-client create wait Admission itself returns false for the closed generation

Validation

Go 1.27.0, Darwin arm64, repository-supported runner and provenance-verified native artifacts:

  • Owning morpc package normal tests passed; the final two client-cleanup edits were additionally checked with their exact normal tests.
  • Complete morpc package with go test -race -p 1 -count=1 ./pkg/common/morpc passed locally (15.671 s).
  • Eight modified asynchronous scenarios each passed individually with -race -count=100.
  • External registration-guard bypass mutation now fails with one factory call versus the expected zero, while the real implementation passes. No production mutation is committed.
  • gofmt, git diff --check, affected-package go vet, configured molint, and golangci-lint 2.14.0 incremental checks passed.

No production or documentation changes; tests are +65/-87 (net -22). These are package-level checks, not a business-workload or total CI performance claim. New-head CI is pending.

Additional local verification after the live-state oracle change:

  • go test -p 1 -count=3 -run '^TestGlobalClientGC_UnregisteredClientIgnored$' ./pkg/common/morpc: passed.
  • go test -race -p 1 -count=5 -run '^TestGlobalClientGC_UnregisteredClientIgnored$' ./pkg/common/morpc: passed.
  • Full go test -p 1 -count=1 ./pkg/common/morpc: passed (13.897 s).
  • gofmt and git diff --check: passed.

@XuPeng-SH
XuPeng-SH requested a review from aptend as a code owner October 7, 2026 22:21
@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.

Review decision: changes required. Submitted as COMMENT because the authenticated account is this PR's author and GitHub rejects self-REQUEST_CHANGES reviews.

Reviewed the complete diff at dc6fecb against f20f5ca, including manager admission, worker processing, stop/drain and backend cleanup ownership.

The overall simplification is sound: idle-GC assertions are stronger, the real getBackend path remains exercised, and the integration sleep had no independent oracle. Production and docs are unchanged; tests are +35/-60, net -25. There were no outstanding human review comments to resolve.

One test-protection regression remains: stopping the manager before observing the unregistered-client result can bypass the eligibility check the test is intended to prove. This is demonstrated by the same production mutation passing the new test and failing the base test, not a speculative concern.

Validation on Go 1.27.0 / darwin-arm64: full morpc package with -race passed (15.201s); directly changed GC scenarios passed individual -race repetitions (100 each). External overlay probe with GOMAXPROCS=1 and the worker registration guards disabled: head test PASS, base test FAIL (backend count 1 instead of 0). No repository source was edited for the probes. Normal green/race results do not catch this lost negative oracle.

Comment thread pkg/common/morpc/client_gc_test.go Resolved
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/S Denotes a PR that changes [10,99] lines labels Oct 8, 2026

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

Decision: APPROVE / no blocking finding at 592587342c2d7085debc5248bb5eecdb9f150d18, against f20f5ca147c44b012343d0f48dfcd84b6a5986a1. COMMENT is used because GitHub does not allow the authenticated PR author to approve their own PR.

Reviewed the complete one-file delivery diff and its manager admission, registration, generation completion, stop/drain and client cleanup consumers. The registration comment is resolved: the admitted state's completion is observed while the manager is live, then independent factory-count and backend-pool oracles reject unauthorized creation. Idle removal and eventual backend destruction remain distinct assertions. Cleanup completes the owned workers; no production state, storage, execution path or runtime cost is added.

The latest test-only increment passes normal and individually selected race count100. The external registration-bypass control fails at the factory-count assertion without an alarm. Still-valid owning morpc normal/race and incremental SCA evidence is reused for unchanged inputs; latest-head Linux UT/SCA and CI Required are SUCCESS. Implementation/docs unchanged; tests +65/-87 (net -22). The extra inactive enqueue has no distinct effect oracle and is non-blocking cleanup, not additional claimed coverage.

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

Decision: APPROVE / no blocking finding at 5925873 against f20f5ca. Main-session deep review only; no subagents. Submitted as COMMENT because this is a self-authored PR. No merge.

The existing client/generation/create-state.done remain the admission and completion authorities. The fixed unregistered-client test waits for that exact request to finish while the manager is live, then checks both zero factory calls and no published backend. Shutdown cannot supply a false negative oracle. Closed-client admission is checked directly; synthetic closed state is restored only after its manager stops and the original owner can close the client. Idle/inactive cleanup checks actual backend removal and the relevant destructor outcome, replacing scheduler sleeps without another state machine or fixture.

The original P2 comment is resolved with causal evidence: exact-head normal/race100 and registration-guard bypass controls from the prior main-session review remain valid by identical complete diff fingerprint; the bypass fails at the factory-call assertion without a process alarm. Full owning normal/race/SCA evidence is retained, and latest Ubuntu UT, Linux SCA and CI Required are SUCCESS. All changed hunks and cleanup owners were reconciled.

Production0, tests+65/-87(net-22), docs0. Deleted delays had no independent oracle; retained scenario identities cover actual async creation, idle-duration exclusion, terminal cleanup and registration rejection. No production runtime/performance contract changes, SQL/wire/disk/auth/compatibility changes, or mandatory architectural-design trigger.

XuPeng-SH added a commit that referenced this pull request Oct 8, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Refs #29249 (ongoing test-quality work; this PR does not close the
tracking issue).

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

Remove disconnected implementation and test scaffolding, and replace
clock waits with observable behavior without weakening the retained
oracles.

- Remove the unused Go async worker pool and private merge simulator,
along with their disconnected tests. Retain the real thread-pool
executor and production merge scheduler; move the existing clock
implementation without changing its behavior.
- Remove commented-out, skipped diagnostic scaffolding and orphan
helpers where they have no active test value. Preserve active
checkpoint, GC, replay, transaction and restart checks; re-enable
meaningful non-voting replica and delete/restart tests.
- Exercise exporter contents directly and lifecycle separately. In the
collector test, assert threshold-triggered SQL publication **before**
stopping, then assert pending-buffer drainage after graceful stop. Both
waits are bounded and cleanup is registered immediately.
- Synchronize asynchronous tests on their actual completion/publication
oracles, including jobs, backend creation and logtail cancellation. Keep
main's canonical GC tests from #29674 intact, including
unregistered-client, idle-close and failure-cleanup assertions.
- Keep prebuild tests independent of host free disk while retaining a
separate low-disk rejection check and real child-process cleanup
assertions.

Final delta against main: 26 files, +483/-4914 lines. No SQL, protocol
or persistent-data-format changes. Existing data compatibility is
unchanged; mixed-version operation is not part of this change.

### Validation

- Complete delivery-diff selection: 16 affected/direct-consumer
packages, including packages containing deleted tests and the real
scheduler's owning DB consumer. Normal UT and race UT both passed (15
test packages; 3,372 test/subtest pass events each, five existing
skips). Both use `-short -tags matrixone_test -count=1` with the
repository CGo wrapper; the testutil support package is compiled but
contains no tests. The skipped tests are not claimed as validated.
- Incremental formatting/diff checks, `go vet`, the repository-pinned
`molint`, and configured golangci-lint 2.14.0 against the final main
base.
- Collector and auto-create tests: 100 race-mode repetitions each.
- Independent white-box negative controls: disabling threshold
publication fails the pre-stop assertion; disabling shutdown drainage
fails the post-stop assertion. Both terminate with cleanup rather than
hanging.
- Design and final complete-change review use `gpt-6.1-sol` with `xhigh`
reasoning. Local terminal evidence is recorded independently of remote
CI.

Removing fixed waits reduces avoidable test delay, but this PR does not
claim a measured whole-suite or production performance improvement.
Remote CI is not used as a substitute for the local gates.

This branch was previously deployed

1 inactive deployment
ci — 3e8f0ca1 Deployed Oct 8, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement kind/refactor Code refactor 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