Skip to content

fix(ci): correct SCA closure and native test lifecycle ownership - #32717

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/main-ci-ut-systematic-20261113T122359Z
Nov 15, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/main-ci-ut-systematic-20261113T122359Z

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Nov 13, 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:

Fixes #32664
Fixes #32706
Fixes #32715

Related to #32544, #32570, #32423, #32422, #32324, #32185 and #32179. These historical incidents are not claimed fixed by this PR; the local controls do not establish their original causes.

Supersedes #32666.

What this PR does / why we need it:

Correct CI dependency selection and test ownership boundaries that cause unnecessary work or make failures wait on resources that cannot complete. The branch is rebased on main. This change does not add runners or change DWARF settings.

  • SCA selection: traverse go list production and test variants before mapping them to package owners, preventing a test-only reverse edge from pulling in unchanged production consumers. Changed production still seeds its variants, and uncertain discovery or broad fan-out still selects full analysis. Real Go/Make fixtures cover both internal and external tests, reverse edges and fallbacks.
  • Bootstrap and transaction metrics: require all five task tables in one successful observation instead of combining partial observations, retaining the original exact test-root name. Exclude heartbeat transactions before the exact commit-counter fixture starts; keep the existing commit and rollback counter assertions.
  • SQL fixture ownership: preserve the prepared-cache scenarios, SQL, data, plans and assertions while giving independent phases bounded child contexts and restoring the AP flag before rollback, including Goexit. Propagate teardown errors so shared fixtures cannot be silently reused after uncertain cleanup. The committed-state assertion remains in the parent test so selecting an existing subtest cannot filter it out. The two-minute per-phase deadlines can extend the total worst-case root timeout relative to the former shared deadline.
  • Frontend construction and tracing: make Stop own the partially constructed routine manager and listeners until successful handoff, retaining the original panic and caller context. The parse-error test restores its borrowed global trace-provider state; without that restoration, later intentionally failing TCP/Unix binds can each wait for the test tracer's acknowledgement. Cover both initial tracer states, all three failure stages, worker/listener cleanup and a real one-CN failure followed by port reuse. The selected local cross-owner race case took 2.47s; this is not an end-to-end job increment.
  • Explicit trace and CDC oracles: retain the original parse-error cases and test both incoming tracer states without repeating its global session fixture. Add explicit active/late transaction ID, peer, memory-epoch, terminal plan summary and failure-log assertions; cover log-field extraction and internal-account filtering in the tracer owner. The existing CDC concurrent restart test remains, with a separate deterministic test of the late-running fallback, owner fence and conflicting states. Its error controls share one bounded child process on the same runner so they cannot consume the parent suite’s log budget; the selected local race root took 1.35s including the child.
  • Catalog replay: run the three fixed-snapshot, read-only replay queries with the existing optimistic transaction mode, so failed startup does not need a heartbeat that was never started to retire its transaction. Preserve the query, snapshot, predicates, workspace, commit/rollback and cancellation behavior. The real-client test checks all three outcomes and cleans up its goroutine by cancelling before joining on a failure path.

Coverage and measurements

No new test skip is introduced and no dataset is reduced.

Existing behavior Mapping after this change
Six parse-error classification cases and four real record calls Retained; the borrowed tracer enabled bit is restored after the original session/controller cleanup. Separate false/true guards cover the cleanup.
Session-manager, TCP and Unix constructor failures All retained with the original panic, context, listener and worker assertions; a real one-CN case checks rollback and port reuse.
Trace-enabled later tests Previously reached through a leaked global bit. Equivalent frontend transaction, peer, resource and log interactions are now explicit; tracer-owned logging and internal-account behavior have their own assertions.
CDC restart timeout and late publication The original concurrent test remains. An added deterministic state/owner matrix verifies the fallback update, conflict handling, account context and exact SQL order.
Prepared-cache and native SQL issue cases SQL, plans, fixtures and result assertions remain; child-context and cleanup ownership change.
BVT scripts, queries and datasets No BVT script is moved; planner/explain query, table and row counts, statistical shape and expected results are unchanged.

The replay lifecycle test adds a real transaction and commit/rollback/cancel checks instead of relying on mocked completion; the frontend and tracing tests retain error and resource-lifecycle checks and add state-restoration checks. Bootstrap and metrics retain exact readiness/counter assertions while isolating their inputs.

On an earlier main graph (1064837ae2), the test-aware selector reduced the queryservice example from the 510-package full graph to 170 packages and protoc to 21; high fan-out still selected the full graph. These are historical graph counts, not a final-head CI time measurement.

Recent main-target UT race jobs took 65m12s, 66m49s and 68m59s end to end. Their slowest SQL-integration workers, not the sum of all case durations, determine that wave's critical path. This PR does not yet establish a whole-job reduction or an under-one-hour result. Before the trace fix on the rebased branch, the leaked tracer caused a same-process focused race run to time out after 20 seconds; on the rebased candidate the same path plus state checks completed in 1.313 seconds of package time. That is a local focused result, not a whole-CI saving.

The earlier proxy BVT job ended with runner shutdown signal / exit 143. The last SQL script had started but had no terminal result and the log contained no script-failure marker. The reason for the runner shutdown is unknown; later runs on other revisions passed that script but cannot establish what happened on the old runner. A new exact-head CI run is required.

Validation

Local checks use Go 1.27.1 on rebased main 3e68780237c. Earlier owning-package results are reused only where subsequent changes were confined to other packages’ test files and did not alter that package’s compiled test closure.

  • CI selector contracts: all 51 Node tests passed, including the real Go/Make fixture and fallback controls.
  • Owning packages: full frontend normal and race passed locally (31.536s / 49.138s package time); full motrace normal and race passed. Full DML and testutils normal/race and full disttae race passed; the local DML package took 52.568s / 148.889s in normal/race modes. Focused affected race tests include the real one-CN failure/rebind, prepared cache, checkpoint, join spill and multi-CN shuffle paths. The pre-existing frontend TestRuleCacheDoubleCheckLocking skip remains.
  • Adaptive race repetitions passed for each affected lifecycle root: the new frontend/tracer roots and related constructor/parse roots each passed 100 times, and the isolated CDC timeout root passed 23 times. The actual one-CN construction failure/rebind passed 12 times; the prepared, snapshot, join-spill and shuffle roots passed 3, 3, 4 and 4 times respectively. No selected iteration was skipped; each of the six log-field subcases also passed when selected independently.
  • A same-selection frontend race/atomic coverage comparison retained all 8,455 original named test/subtest terminal sequences. The 22 baseline frontend blocks not exercised in the final frontend run are exercised by the motrace owner with explicit matching oracles; no compared block remained unmapped. The diagnostic comparison excludes the constructor and parse-tracer guard in both versions; full owner runs include them. The old bootstrap root and the two original prepared-cache subtest selections were also verified explicitly. The CDC child coverage merge and individual subtest selection were verified separately.
  • Fault-injection overlays make the new transaction-ID, resource, outer-statement, EOF, CDC fallback, logging and account-filter checks fail as intended. Separate missing-restore and Goexit probes verify both incoming tracer states; probe-only skips are not submitted tests.
  • Full configured make static-check-analysis passed before the final test-only additions. On the final affected closures, configured molint and golangci-lint passed for frontend, motrace, disttae, DML and testutils (0 reported issues), with affected go vet, formatting and git diff --check passing.

Design and the final diff are reviewed with gpt-6.1-terra / max. The pushed head still requires its own complete remote CI; results from the old head are not treated as final verification.

@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 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Nov 13, 2026
@XuPeng-SH

XuPeng-SH commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 0a6c008de2989991d2fde56b42a2b7575c4da476

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: 0a6c008de2989991d2fde56b42a2b7575c4da476

Assessment: approve

The complete 14-file change repairs existing ownership and dependency boundaries. Frontend construction reuses Stop, fixed-snapshot replay retains workspace finalization while avoiding premature lock cleanup, and variant selection preserves Go's graph identities. Test corrections retain existing SQL/data/plan and exact metric oracles without adding another lifecycle or retry mechanism. No actionable defect found.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • All 51 Node CI contracts passed, including the real Go inventory/Make consumer: checks/1794581674657146165-2.json and ci-contracts.stdout.log.

  • Exact bootstrap source/test files passed with Go 1.27.1, -race -count=1 and the assigned test executor: three roots and four incomplete-observation controls. Receipt checks/1794581852532165716-2.json; bootstrap-race-official.stdout.log. This is a standalone-file check, not the full native owning package.

  • Isolation preflight, formatting and final source/discussion/receipt audit passed: checks/1794582157390910101-2.json and review-audit.json. All 14 changed paths, three discussion items and ten linked issues were covered.

  • Detailed frozen author reports of frontend/disttae/testutils/txnbase normal/race, focused lifecycle repetitions, native SQL and cross-owner failure controls were assessed and reused with attribution; closure-review.md records the ownership and oracle analysis.

Limitations:

  • Full native packages and embedded lifecycle cases were not independently rerun locally; native prerequisites and raw author execution artifacts were not supplied in local_validation.

  • Hosted UT, SCA and coverage were pending in the frozen evidence. Reported controlled native passes do not establish full-lane stability or resolve the seven historical incident trackers.

@XuPeng-SH
XuPeng-SH force-pushed the codex/main-ci-ut-systematic-20261113T122359Z branch from 0a6c008 to b40bfd7 Compare November 15, 2026 02:32
@XuPeng-SH
XuPeng-SH requested a review from aptend as a code owner November 15, 2026 02:32
@matrix-meow matrix-meow added size/XL Denotes a PR that changes [1000, 1999] lines and removed size/L Denotes a PR that changes [500,999] lines labels Nov 15, 2026
@XuPeng-SH

XuPeng-SH commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: b40bfd75b5a4b2e073cff8f5d3e78b61545aecaf

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: b40bfd75b5a4b2e073cff8f5d3e78b61545aecaf

Assessment: approve

Complete 18-file review found no actionable defects. The fixes reuse existing cleanup, transaction and dependency owners. Scoped tracing fixtures and one bounded CDC child preserve isolation and explicit assertions.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed the complete delta, six discussion entries and ten linked issues. Saved review-plan.md, discussion-assessment.json and closure-review.md.

  • All 51 Node CI contracts passed, including real Go inventory and Make consumer controls: checks/1794711052823893219-2.json and ci-contracts.stdout.log.

  • Isolation preflight passed: checks/1794711034826683952-2.json.

  • Clean frozen source, diff checks, formatting of 16 Go files and discussion coverage passed audit: checks/1794711450138240548-2.json and review-audit.json.

  • Assessed and reused the frozen author's detailed native package, race, coverage and fault-control reports with attribution.

Limitations:

  • Local bootstrap race validation did not compile with Go 1.26.6; required Go 1.27.1 download timed out. Receipts: checks/1794711089469309952-2.json and checks/1794711199467997389-2.json.

  • Native packages were not independently rerun. Checkout prerequisites and raw author validation artifacts were unavailable.

  • Hosted UT, SCA, coverage and selected BVT remained in progress. Full-lane stability, coverage-retention measurements and historical incident fixes are not independently established.

@XuPeng-SH
XuPeng-SH merged commit d1893e5 into matrixorigin:main Nov 15, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/main-ci-ut-systematic-20261113T122359Z branch November 15, 2026 03:57
XuPeng-SH added a commit that referenced this pull request Nov 15, 2026
## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to #27705 and #27076, earlier work to reduce CI wall time and
duplicated setup/report work. Both issues are already closed; this is a
follow-up.

This also continues the main CI optimization after PR #32717.

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

The UT setup summary previously decoded the complete JSON report twice:
once for setup totals and once for admission-holder evidence. It now
gathers both during the normal scan, retaining the existing independent
filters, error ordering and output. Provisional holder state is bounded
before the first valid setup total; if that bound is exceeded and totals
are found, the existing separate holder scan is used as a fallback.
Reports without totals do not retain unbounded holder state.

On one 329 MB historical local race report, three alternating warm-cache
runs of the summary parser took 4.548–4.585 s before and 2.176–2.204 s
after. On a 64 MB SQL integration report, the corresponding times were
0.748–0.754 s and 0.360–0.365 s. In each comparison stdout, stderr and
exit status were identical. These measurements are local parser times,
not an estimate of full CI job savings; this change alone does not reach
the one-hour race UT target.

No test cases, test order, runner count, DWARF flags, or report contents
are changed.

## Validation

- Full `./optools` normal test run: 94 top-level tests passed, no skips.
- Six relevant setup-summary and admission-holder tests passed in normal
and `-race` modes, including malformed JSON, independent filters,
bounded provisional state and error precedence.
- Differential controls exercised large/no-total reports and randomized
event streams; before/after output and exit behavior matched.
- `go vet`, repository-configured `make static-check-selected
STATIC_CHECK_PACKAGES=./optools`, gofmt and `git diff --check` passed.

On the previous head `d334217316d`, CI run 43691228594 attempt 2 passed
SCA, UT coverage and both BVT jobs, but race UT failed in
`logservicedriver.Test_Replayer9`: an injected cancellation cause was
reported as `context canceled`. A separate WAL repair remains under
investigation. On the rebased head
`4b6cedf4317cea5dbeaea7c097cff41f6e00ee3b`, CI run 43703688237 passed UT
race, SCA, UT coverage, both BVT jobs and CI Required. The full UT race
job took 65m28s (Unit Testing 63m30s); the previous successful
main-target job took 65m29s, so this does not establish a whole-job
speedup.
XuPeng-SH added a commit that referenced this pull request Nov 15, 2026
## What type of PR is this?

- [x] BUG
- [x] Test and CI

## Which issue(s) this PR fixes:

Related to #28933 and PR
#32717. This PR does not claim to fix the already closed issue.

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

When cancellation interrupts batched race-test preparation, an ordinary
preparation error can currently start a complete fallback `go test`
after the parent has already requested termination. A controlled
reproduction using the real parent/helper and a blocked mock `sort` also
observed a successful helper acknowledgement; the outer job still exited
143. This PR does not claim an observed false-green CI job.

Carry the cancellation request through preparation, dispatch and
completion; prevent a cancelled preparation from starting the fallback;
and retain ownership of an admitted fallback until it is drained. On
Linux with Bash 5 or newer, a verified parent-owned process group keeps
the fallback reachable even if the helper dies before publishing its
child PID. Non-Linux, older Bash, or unverified ownership retain the
original foreground fallback. Ordinary preparation failures still use
the complete fallback and preserve its flags, timeout budget, standard
input, output, and selected status.

If the runner cannot prove a prebuilt writer has stopped, retain its
partial reports as explicitly live, non-authoritative diagnostics rather
than merging them as a complete result. Later runs move these generated
directories out of the current artifact directory into workspace scratch
without deleting them. Persistent workspaces have no automatic retention
limit for these archived hard links, and the CI diagnostic artifact
quota may omit or truncate them.

This is a cancellation reliability fix, not an established whole-job
speedup. It does not add runners, change DWARF flags, or remove any test
case.

## Validation

- Go 1.27.1: full `./optools` normal and race runs with `-short -tags
matrixone_test -p 1 -parallel 4 -count=1` each passed 120 roots and 486
named test/subtest terminals, with identical terminal sets and no
failures or skips.
- Actual parent/helper controls cover cancellation during preparation
and dispatch, cancelled versus ordinary fallback, partial report
ownership, repeated TERM, fallback and helper SIGKILL, and an unjoined
writer. The original runner fails the preparation-cancellation control
by starting the mock fallback. Separate test-only controls for an
incorrect outer grace and a suppressed KILL fail their assertions as
intended.
- The fallback preserves standard input and Go driver/test-process
INT/QUIT dispositions in the tested Linux configurations. Bash 5.0 and
5.1 receive focused race controls. These tests compare signal
dispositions; they do not establish every actual INT/QUIT delivery
window. A descendant that explicitly leaves the original process group
remains outside its drainage guarantee.
- Repository-configured `make static-check-selected
STATIC_CHECK_PACKAGES=./optools`, `go vet`, `gofmt`, `bash -n
optools/run_ut.sh`, and `git diff --check` passed. The configured linter
excludes one existing test-file staticcheck finding.
- Final overall review: gpt-6.1-terra / max, on the same complete diff.
The committed branch is rebased onto main
`f70c37b16e2d2378dd6d48775df0f29c610dce6b`.

Remote CI on this exact head is pending. The full race UT target of
under one hour remains open.

This branch was previously deployed

1 inactive deployment
ci — b40bfd75 Deployed Nov 15, 2026 by XuPeng-SH
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/enhancement kind/test-ci size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

3 participants