Repository navigation
fix: eliminate CI test lifecycle leaks and metric flakiness - #27480
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Follow-up on the failed coverage check:
Linux/arm64 reproduction with |
|
Scope correction completed in f12d818: the four native/CGo link-contract files were restored to the PR base. #27480 now contains only the lifecycle leak and hardware-metric test fixes, so matrixorigin/CI#429 is no longer required for this PR. The earlier loader failure was caused by the bundled native-link change, not by the lifecycle fixes. |
…igin#27480) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27452 Fixes matrixorigin#27412 Fixes matrixorigin#27408 ## What this PR does / why we need it: This fixes the underlying lifecycle and measurement contracts behind the two CI failures instead of reducing coverage scope, weakening assertions, or rerunning deterministic failures. ### Coverage OOM root cause Heap profiling of the exact 462-package coverage shape showed that repeated `MockCompilerContext.GetProcess` calls created fresh `Process` instances. Each `Process` then replaced the service runtime's `AutoIncrementService`. The displaced services retained background workers and caches, so the plan test process grew to about 12 GiB and was killed by the 14 GiB runner cgroup. - Reuse one `Process` for each mock compiler context, matching the compiler-session contract. - Preserve that identity when constructor-created mock contexts are copied by sharing a holder instead of copying synchronization state. - Make `testutil.SetupAutoIncrService` concurrency-safe and idempotent per service runtime. - Add concurrent regression tests for constructor-created, literal, and copied mock contexts and for auto-increment service identity. The same full `pkg/sql/plan` suite with the CI 462-package `coverpkg` list passes with peak RSS reduced from 12,537,728 KiB to 269,880 KiB (97.85%). Coverage scope and test parallelism are unchanged. ### Hardware CPU test root cause The old assertion compared a cumulative busy-seconds delta with `cpu.Percent` sampled over a different time window. Those values are not mathematically comparable under changing runner load. The test now validates each metric's actual contract independently: percentage is bounded to `[0, 100]`, the cumulative counter is non-negative, and the counter is monotonic. The unnecessary one-second sleep is removed. ### Scope decision Native/CGo dependency-closure hardening is independent of these lifecycle and metric fixes. It has been removed from this PR so the change remains reviewable and continues to use the current `main` CI link contract. Any native-link hardening should be reviewed separately with its matching MatrixOne and CI changes. ### Validation - Exact 462-package `coverpkg` full `pkg/sql/plan` suite. - Each new/changed regression test with `-race -count=100`. - Full `pkg/sql/plan`, `pkg/testutil`, and `pkg/util/metric` suites with `-race`. - Full normal tests for all three owning packages. - `go build` and `go vet` for all modified Go packages. - `git diff --check` and explicit verification that the four native/CI files match the PR base.
…igin#27480) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27452 Fixes matrixorigin#27412 Fixes matrixorigin#27408 ## What this PR does / why we need it: This fixes the underlying lifecycle and measurement contracts behind the two CI failures instead of reducing coverage scope, weakening assertions, or rerunning deterministic failures. ### Coverage OOM root cause Heap profiling of the exact 462-package coverage shape showed that repeated `MockCompilerContext.GetProcess` calls created fresh `Process` instances. Each `Process` then replaced the service runtime's `AutoIncrementService`. The displaced services retained background workers and caches, so the plan test process grew to about 12 GiB and was killed by the 14 GiB runner cgroup. - Reuse one `Process` for each mock compiler context, matching the compiler-session contract. - Preserve that identity when constructor-created mock contexts are copied by sharing a holder instead of copying synchronization state. - Make `testutil.SetupAutoIncrService` concurrency-safe and idempotent per service runtime. - Add concurrent regression tests for constructor-created, literal, and copied mock contexts and for auto-increment service identity. The same full `pkg/sql/plan` suite with the CI 462-package `coverpkg` list passes with peak RSS reduced from 12,537,728 KiB to 269,880 KiB (97.85%). Coverage scope and test parallelism are unchanged. ### Hardware CPU test root cause The old assertion compared a cumulative busy-seconds delta with `cpu.Percent` sampled over a different time window. Those values are not mathematically comparable under changing runner load. The test now validates each metric's actual contract independently: percentage is bounded to `[0, 100]`, the cumulative counter is non-negative, and the counter is monotonic. The unnecessary one-second sleep is removed. ### Scope decision Native/CGo dependency-closure hardening is independent of these lifecycle and metric fixes. It has been removed from this PR so the change remains reviewable and continues to use the current `main` CI link contract. Any native-link hardening should be reviewed separately with its matching MatrixOne and CI changes. ### Validation - Exact 462-package `coverpkg` full `pkg/sql/plan` suite. - Each new/changed regression test with `-race -count=100`. - Full `pkg/sql/plan`, `pkg/testutil`, and `pkg/util/metric` suites with `-race`. - Full normal tests for all three owning packages. - `go build` and `go vet` for all modified Go packages. - `git diff --check` and explicit verification that the four native/CI files match the PR base.
…igin#27480) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#27452 Fixes matrixorigin#27412 Fixes matrixorigin#27408 ## What this PR does / why we need it: This fixes the underlying lifecycle and measurement contracts behind the two CI failures instead of reducing coverage scope, weakening assertions, or rerunning deterministic failures. ### Coverage OOM root cause Heap profiling of the exact 462-package coverage shape showed that repeated `MockCompilerContext.GetProcess` calls created fresh `Process` instances. Each `Process` then replaced the service runtime's `AutoIncrementService`. The displaced services retained background workers and caches, so the plan test process grew to about 12 GiB and was killed by the 14 GiB runner cgroup. - Reuse one `Process` for each mock compiler context, matching the compiler-session contract. - Preserve that identity when constructor-created mock contexts are copied by sharing a holder instead of copying synchronization state. - Make `testutil.SetupAutoIncrService` concurrency-safe and idempotent per service runtime. - Add concurrent regression tests for constructor-created, literal, and copied mock contexts and for auto-increment service identity. The same full `pkg/sql/plan` suite with the CI 462-package `coverpkg` list passes with peak RSS reduced from 12,537,728 KiB to 269,880 KiB (97.85%). Coverage scope and test parallelism are unchanged. ### Hardware CPU test root cause The old assertion compared a cumulative busy-seconds delta with `cpu.Percent` sampled over a different time window. Those values are not mathematically comparable under changing runner load. The test now validates each metric's actual contract independently: percentage is bounded to `[0, 100]`, the cumulative counter is non-negative, and the counter is monotonic. The unnecessary one-second sleep is removed. ### Scope decision Native/CGo dependency-closure hardening is independent of these lifecycle and metric fixes. It has been removed from this PR so the change remains reviewable and continues to use the current `main` CI link contract. Any native-link hardening should be reviewed separately with its matching MatrixOne and CI changes. ### Validation - Exact 462-package `coverpkg` full `pkg/sql/plan` suite. - Each new/changed regression test with `-race -count=100`. - Full `pkg/sql/plan`, `pkg/testutil`, and `pkg/util/metric` suites with `-race`. - Full normal tests for all three owning packages. - `go build` and `go vet` for all modified Go packages. - `git diff --check` and explicit verification that the four native/CI files match the PR base.
## What type of PR is this? - [x] BUG - [x] Improvement ## Which issue(s) this PR fixes: Fixes #32221 ## What this PR does / why we need it: A point update of an indexed column can scan the full secondary-index table when default or stale statistics cause the runtime-filter cost heuristic to reject the maintenance join. With two maintained indexes, each scan can read all 50,000 rows even though the base primary-key lookup returns one row. When an otherwise rejected broadcast INNER join has an ordered full-PK probe and its build is provably at most one row, admit the existing exact runtime filter without changing statistics or join placement. The proof supports a conservative chain of unique-key joins so multiple regular indexes can be maintained selectively. It verifies source index ownership and the full untruncated integer primary key, worker-invariant join expressions, and matching filter dependencies; unsupported shapes retain existing costing. The execution path, memory accounting, and PASS/error behavior remain owned by the existing runtime-filter implementation. Historical feature validation on Go 1.26.4 with `GOEXPERIMENT=simd` and `GOAMD64=v3`, before the CI repair follow-up: The live service experiments used the preceding candidate build. The final commit relaxes only a cross-table schema-version comparison; both scan references in those experiments use version zero, so their execution behavior is unchanged. The original feature validation below predates the CI repair follow-up. - Full `pkg/sql/plan` tests and race tests; focused HashBuild optional-budget, cleanup, and reset race tests; focused compile broadcast/runtime-filter topology race tests. - SQL BVT on a two-index table: 29/29, including prepared reuse, NULL, rollback, primary-key change, and forced-index readback. A prepared UPDATE was also reused successfully after dropping and recreating an index. - Two-CN forced AP: both index scans read one row; checked commit/rollback, 20 concurrent updates to the same row from both CNs, direct hidden-index entry counts during repeated changes, cancellation, invalid prepared parameter, NULL, and missing key. - Local 50,000-row two-index reproduction, 5 warmups and 20 measured transactions: point-update median **15.47 ms → 1.22 ms**, with each index scan **50,000 → 1** input row; 1,000-row range median **19.66 ms → 19.70 ms**. Separate sequential service runs include client and transaction overhead. In the forced two-CN AP setup, point median was **91.14 ms → 91.56 ms** despite the scan reduction, so no AP latency improvement is claimed. - Incremental `gofmt`, `go vet`, and repository-pinned `golangci-lint` pass for the changed packages. The repository's custom `molint` also reports three existing findings in untouched `expr_opt.go` and `returning.go`. The proof deliberately falls back for unrecognized index metadata, unsupported predicates/types, partitioned sources, and other unproven join shapes. CI for the updated branch is pending. ### CI reliability follow-up The failed Ubuntu race job exposed a shutdown wait: the transaction trace watcher could enter a synchronous statistics lookup that did not wake when its caller was canceled. It also exposed timing-sensitive CDC and file-service tests. The arm64 static-analysis runner was OOM-killed at its 8 GiB limit while using the legacy full-check path. - Backport cancellation-aware statistics waiting and forced-queue admission, and propagate the trace worker's stop context through its queries, writes, queue handoff, and retry wait. Trace data during shutdown remains best effort. - Replace timing-sensitive test assertions with controlled progress and cleanup. The file-service range test verifies the actual configured wait bound with virtual time. - Backport runtime-scoped, idempotent auto-increment service setup from #27480 and reuse each mock planner context's process. This prevents repeated test fixture creation from orphaning background workers; clean up fixture pools and restore overridden test services. - Enable the existing split static-analysis workflow on 4.2 and limit its Go and lint concurrency while retaining the full legacy target and license checks. This is an OOM mitigation; the arm64 runner still needs to validate it. ### CI repair validation - `pkg/cdc`, `pkg/fileservice`, `pkg/txn/trace`, and `pkg/vm/engine/disttae`: full package race tests; 13 named concurrency tests each repeated 100 times under race. - `pkg/embed.TestBasicCluster`: race test using `-short -tags matrixone_test`. - `pkg/sql/plan`: the full package now passes in a single `-short -race -tags matrixone_test` process (5.00 s). A previous full run before the fixture fix was OOM-killed at a 10 GiB cgroup limit; after the fix, a complete run peaked at 1,148,952,576 bytes (about 1.07 GiB). These are not two completed-run benchmarks. - `pkg/testutil`, `pkg/sql/plan/tools`, `pkg/sql/colexec/hashbuild`, and `pkg/sql/compile`: full package race tests. Selected service-ownership, planner-context, and runtime-filter tests each passed 100 repetitions under race. - Incremental `gofmt`, `go vet`, pinned `molint`, and configured golangci-lint across 11 changed or directly affected packages; full license header and dependency checks. The local x86_64 check ran in an 8 GiB cgroup, peaking at 6,646,784,000 bytes (about 6.19 GiB) with no OOM events. After the final fixture cleanup, planner vet, molint, and golangci were rerun. `molint` reported ten existing unsafe-recover diagnostics in seven files unchanged from the merge base; it reported none in changed files. - On the preceding CI-repair snapshot, full x86_64 `make static-check-analysis GOLANGCI_LINT_CONCURRENCY=1` with `GOMEMLIMIT=3GiB` exited 0; repository-configured golangci-lint reported 0 issues. The full molint run also emitted existing diagnostics in unchanged baseline files. The final planner-fixture follow-up was covered by the incremental checks above. - CN shutdown consumers: three focused race tests, including trace-producer shutdown, passed. The updated head's arm64 SCA and complete CI remain to be verified.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #27452
Fixes #27412
Fixes #27408
What this PR does / why we need it:
This fixes the underlying lifecycle and measurement contracts behind the two CI failures instead of reducing coverage scope, weakening assertions, or rerunning deterministic failures.
Coverage OOM root cause
Heap profiling of the exact 462-package coverage shape showed that repeated
MockCompilerContext.GetProcesscalls created freshProcessinstances. EachProcessthen replaced the service runtime'sAutoIncrementService. The displaced services retained background workers and caches, so the plan test process grew to about 12 GiB and was killed by the 14 GiB runner cgroup.Processfor each mock compiler context, matching the compiler-session contract.testutil.SetupAutoIncrServiceconcurrency-safe and idempotent per service runtime.The same full
pkg/sql/plansuite with the CI 462-packagecoverpkglist passes with peak RSS reduced from 12,537,728 KiB to 269,880 KiB (97.85%). Coverage scope and test parallelism are unchanged.Hardware CPU test root cause
The old assertion compared a cumulative busy-seconds delta with
cpu.Percentsampled over a different time window. Those values are not mathematically comparable under changing runner load.The test now validates each metric's actual contract independently: percentage is bounded to
[0, 100], the cumulative counter is non-negative, and the counter is monotonic. The unnecessary one-second sleep is removed.Scope decision
Native/CGo dependency-closure hardening is independent of these lifecycle and metric fixes. It has been removed from this PR so the change remains reviewable and continues to use the current
mainCI link contract. Any native-link hardening should be reviewed separately with its matching MatrixOne and CI changes.Validation
coverpkgfullpkg/sql/plansuite.-race -count=100.pkg/sql/plan,pkg/testutil, andpkg/util/metricsuites with-race.go buildandgo vetfor all modified Go packages.git diff --checkand explicit verification that the four native/CI files match the PR base.