Skip to content

refactor(sql): consolidate active owners and retire obsolete paths - #29574

Merged
XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/quality-29249-20261003
Oct 3, 2026
Merged

XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/quality-29249-20261003

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Latest checkpoint: 0a73284 (2026-10-03)

Non-final checkpoint. Overall PR readiness remains blocked: full function race FAILED.
Read-only gpt-6.1-sol / xhigh approved committing/pushing this narrow stage
under the explicit staging request, with the failed gate left open.

  • Fixture-only +9/-3: release simulated atomic unlock blockers after assertions,
    then reuse the existing generation/reset/join owner. No production or dependency edit.
  • 74 related lock tests pass normally; all 74 lock cases pass within the failed
    full-race run. The two benefited tests each pass 100 individual race repetitions.
  • Six complete normal package runs pass. Three alternating serial pairs yield
    medians: wall 11.750s → 9.869s (-16.0%), CPU 2.081s → 2.451s (+17.8%),
    peak RSS 209.7MiB → 199.9MiB (-4.7%). No CPU-saving or whole-CI claim.
  • Configured incremental golangci-lint: PASS, 0 issues. MO-specific lint has no
    incremental findings; its two unchanged unsafe diagnostics match prior evidence.
  • Full function race fails TestRegexp2EvaluationAdmissionRejectsUnboundedRunnerGrowth
    with an engine timeout on the admitted positive control. Verified clean baseline
    full race passes. Separate dependency probes prove serial/concurrent clock defects;
    they do not establish causality for the full-package failure. Complete compatible
    clock backport and final race validation remain pending; v1.11.5 upgrade withdrawn.

Review/evidence summary is committed in
docs/design/20261003-expression-quality-consolidation.md.
Refs #29249; continuous tracking remains open.


What type of PR is this?

  • Improvement
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Refs #29249.

What this PR does / why we need it:

Consolidates expression execution around the existing production owners and removes retired implementations with their exclusive tests.

  • Share checked calendar/time arithmetic across six temporal ADD/SUB adapter pairs. Preserve selection, NULLs, warning policy, timezone and precision.
  • Reduce TIMESTAMPADD DATE's eight wrapper-dependent loops to four batch-dispatched loops (constant/dynamic unit × DATE/DATETIME output). Keep unit admission, one result conversion, and existing calendar/diagnostic owners. A tiny NULL helper is inlined; error handling is shared on the failure path. No parsed-unit cache or persistent state. Return failed DATE→DATETIME allocation before accessing backing memory.
  • Validate literal source metadata before allocation; consolidate constructor failure cleanup while preserving non-NULL domain/binary behavior.
  • Retire unused Iceberg remote scaffolding while retaining the active local coordinator, catalog/credential checks and ObjectIO lifetime.
  • Retire test-only prepared/auth wrappers and obsolete schema/index/flat-ring geometry helpers. Retained tests exercise active scoped authorization, logical schema admission, contiguous index prefixes and geometry owners.
  • Consolidate repeated fixtures while retaining literal results, result metadata, folded residual execution, allocation baselines and failure controls.

Against main 9078a8bd87af49ea06f52e09d64e7740122aea61: 27 files. Implementation +257/-1189, tests +1890/-3936, design documents +161/-0. Counts describe each increment; they do not establish correctness or imply an audit of every recently changed module.

Current optimization validation

Local Go 1.26.4/Linux amd64 with fresh native CGo inputs, GOMAXPROCS=2, GOMEMLIMIT=2GiB, build concurrency1; heavy checks run sequentially on the shared machine.

  • Full function package count1 PASS (14.982s), including 2,304 other temporal ADD/SUB differential scenarios and 2,496 TIMESTAMPADD DATE scenarios against the original baseline, plus literal expected-value and denied-growth account/vector controls.
  • Focused DATE race PASS (2.386s). Strengthened admission-before-warning test rerun normally and with race PASS (1.139s); a later invalid unit must prevent earlier overflow warnings and metadata writes. Four loop modes preserve exactly one warning per selected overflowing row with constant operands.
  • Actual binder/executor reuse PASS (11 batches, sizes0..2048, masks, NULLs and precision transitions).
  • Single-CN SQL frontend replay of the existing func_datetime_timestampadd.test/.result PASS: all56 statements, exact headers and rows, DATE/DATETIME/TIMESTAMP, NULL, overflow and WHERE controls. Uses the existing integration fixture and task-private temporary files; no new cluster fixture is shipped. This is the targeted SQL BVT, not a full multi-CN rerun.
  • Incremental owning-package golangci-lint v2.6.2 PASS, no findings. Repository-pinned molint exits0 with the same two pre-existing unsafe diagnostics in unchanged files as the prior successful CI; no new diagnostics. Formatting/diff checks PASS.
  • All six shipped lightweight benchmark cases execute successfully.

Expression CPU performance

Exact baseline, pre-optimization PR body and candidate run in the same binary on reused2048-row vectors; caller bound type reset each batch. Primary cases measured in both orders, five500ms samples each, unchanged allocations. Reverse-order medians (ns/batch):

Case Original baseline Before optimization Candidate Candidate vs baseline
Fixed DAY 36,146 35,263 34,389 -4.86%
Fixed SECOND 32,650 33,613 32,762 +0.34%
Dynamic DAY/HOUR 158,729 161,642 160,331 +1.01%

First-order candidate deltas: DAY-4.79%, SECOND-0.87%, dynamic+0.88%. MICROSECOND, MONTH and dynamic DATE-only controls remain close to baseline (-0.87%..+0.32%). Scalar dates have no allocation increase. Partial masks/NULLs retain small differences (SECOND+1.08%, dynamic+1.27%). Seven-row SECOND remains299.5→322.3ns (+22.8ns/+7.61%) versus baseline, slightly faster than pre-optimization324.9ns. These limits are disclosed; the change does not claim every input is faster. Shared-machine microbenchmarks do not establish whole-query or TPCC speedup.

Overall review and historical evidence

CI at f13510d9524284347ace0dd47884a43f58680262 passed: SCA, normal UT, build, coverage and multi-CN proxy/pessimistic BVT (run 37079464383). Dedicated Iceberg E2E was skipped. This follow-up only deletes redundant tests; new-head CI remains pending after push and is not awaited.

Actual gpt-6.1-sol/xhigh design and final overall review evidence: Design session 01a0fed4-73e0-72f2-a61c-a6e33e7cc7f6; final review session 01a0ff00-0445-78f1-9eca-d5843f425059 (APPROVE, no unresolved material blocker). Actual model and effort verified from both session contexts; final reviewed diff SHA-256 f93173c32478b36d47ac9e920564d1846c8e057b5f9cf00181e5f5108e7bb070.

Final test-quality cleanup

Remove three obsolete branch-oriented temporal tests (72 lines) whose nonzero/optional-error assertions allowed incorrect identity behavior. Exact calendar values and scaling overflow remain covered by TestCalendarIntervalArithmetic; UTC conversion rejection and accepted neighbors remain covered by TestTimestampArithmeticUtcLowerBound; upper overflow, NULL and row isolation remain covered through the real adapters by TestTemporalMicrosecondBoundaryOverflowIsNull. No runtime code changes or replacement fixtures.

These three retained suites passed once on Go 1.26.4/macOS arm64 with the native CGo wrapper (-v -count=1, 0.762s); diff checks passed. Existing mutation evidence demonstrates the weak tests accepted a broken implementation while the canonical table rejected it; those unchanged tests required no repeat mutation or benchmark run.

Follow-up design session 01a0ff65-e236-74e1-9b13-725a5ffcaddf and final overall review session 01a0ff69-39f6-7ec2-8cf6-01a242b577a9, both verified actual gpt-6.1-sol/xhigh. Final review PASS, no actionable findings; the prior P3 is closed.

Staged coverage and fixture-lifetime audit

Refs #29249 (ongoing tracking issue; remains open). This stage preserves the remote test retirement and changes four existing test files plus the existing expression design document; no production behavior, framework, heavyweight fixture or additional test is introduced. Stage delta: +174/-55.

  • Register existing process/vector/result/account cleanup immediately, including partially initialized raw constant constructors and unexpected non-nil executors on error. Payload probes release before the constructor under test; account Seal and Finalize both execute before teardown failure reporting. Body assertions remain before fallback cleanup.
  • Publish all 43 retired top-level test names with retained named scenarios or explicit retirement rationale, plus transformed subcases and forwarding-wrapper ownership, in docs/design/20261003-expression-quality-consolidation.md (revision 2).
  • Current local Go 1.26.4/Linux amd64: all 9 affected tests pass normally and with -race -tags=matrixone_test -count=1; complete owning packages pass (function 14.120s, colexec 0.171s). Heavy runs are serialized with GOMAXPROCS=2, GOMEMLIMIT=2GiB and -p=1.
  • Configured owning-package golangci-lint: 0 issues. Pinned molint exits 0 with seven existing unchanged-source diagnostics (two unsafe imports and five recover calls), matching prior successful CI. No new diagnostic; formatting and diff checks pass.
  • Existing public SQL replay, real executor reuse and expression microbenchmarks remain semantically valid because this stage changes test cleanup and documentation only. No same-condition suite-cost baseline was measured; line counts/package times do not establish CPU, memory or CI-time savings. Cluster setup, admission wait, service startup and scenario costs are reported separately in the design document.
  • Known follow-up boundaries remain explicit: outer zonemap scratch-cleanup mutation previously survived; credential/local coordinator tests are not remote-policy E2E proof; dedicated Iceberg E2E was skipped. These are not relabeled as passes.

Stage design: actual gpt-6.1-sol/xhigh session 01a0ff9d-f447-7d91-9776-444b7e87a846 (ACCEPT). Final stage/overall reconciliation: actual gpt-6.1-sol/xhigh session 01a0ffb1-e7d3-73e2-85a8-5e68591d3792 (APPROVE, no unresolved material blocker). Reviewed stage diff SHA-256 c9c38795143cbcfb1a20a9deb7712efb26aaa48b4b286692ddc1fc9fbc814ee4. New-head CI is not awaited or claimed green.

Follow-up: zonemap scratch cleanup oracle

Strengthen the two existing round/scalar overflow cleanup suites with pre-fallback Go-heap ownership baselines and explicit cleared-slot assertions (+10 test lines, +8 documentation lines; no production changes or new fixture). CurrNB() alone observes native bytes and missed Go-heap operand ownership.

  • Frozen overlay removing the outer cleanup: old scalar/tuple probes pass (0.039s); strengthened round and signed/unsigned scalar tests fail on 32 live Go-heap bytes (0.040s).
  • Independent overlay frees vectors but retains pointers: heap baselines pass, nil-slot oracles reject stale scratch pointers (0.044s). Both mutants fail in test bodies before fallback cleanup.
  • Normal full colexec package PASS (0.150s); both existing suites race PASS (1.147s), count1, controlled native wrapper and serialized runs. Incremental golangci: 0 issues; pinned molint exits0, changed external test package reports no diagnostics. Formatting/diff checks pass.
  • Actual gpt-6.1-sol/xhigh review session 01a0ffbe-f5b8-7890-adcc-c93a54702beb: APPROVE, no concrete blocker. Reviewed diff SHA-256 27741a5b9941e2e5f01f6c06588b300334e82f577a28ab0b4c91ab580c8e31e0.

The prior surviving-mutation boundary is now closed for these exact two errors; no arbitrary leak coverage, test-cost or new-head CI claim. #29249 remains open.

DATE_FORMAT fixture compression with measured owning-package savings

Replace seven obsolete initializers and repeated execution blocks with one explicit literal table and one DateFormat-specific adapter. TestFormat's four duplicate pairs merge into TestDateFormat/all_tokens; six named format subtests retain all 24 original date/result pairs byte for byte. Correctness workload falls from 600 cases / 4,915,200 rows to six cases / 24 rows. Existing per-row format, NULL, masked selection and zero-date oracles retain their behavior, with cleanup-only changes. Inputs and result wrappers now release before their process; native and Go-heap ownership are checked after case cleanup.

Six existing benchmark names, format assignments, 100×8192 population and per-case BenchMarkRun()→Run() sequence remain. Benchmark iteration/timing policy is unchanged; no production edit or new heavy fixture. The exact map and measurement limits are in the existing expression design document.

Three serial, alternating measurements per compiled binary on identical runtime/native/dependency inputs, excluding compilation; all six complete function package runs PASS:

Owning function package Before compression (c161ffc580) After Median change
Wall seconds 13.625 11.846 −13.1%
CPU seconds (user+system) 4.431 2.618 −40.9%
Peak RSS MiB 487.2 208.5 −57.2%

Wall ranges: before13.573–13.697s, after11.825–11.850s. CPU ranges: before4.428–4.643s, after2.407–2.620s. RSS ranges: before478.9–491.4MiB, after200.4–215.7MiB. Runtime uses monotonic timing and terminated-child wait4 CPU/RSS. Source-derived input/result/bool backing arrays fall121.875MiB→624bytes; this excludes vector storage/allocator overhead and is distinct from process RSS. These results establish owning-package savings on this shared machine, not whole-CI or production-query speedup.

Exact final source focused normal selection PASS; three focused suites race PASS1.165s including six format scenarios and unchanged edge suites. Configured incremental golangci:0issues; pinned molint exits0 with only two unchanged unsafe-import diagnostics; formatting/diff checks PASS. Six complete package cost runs are the normal full-package validation. No new BVT is required because public/product behavior is unchanged; existing real SQL evidence remains valid. Benchmark sources are compiled and shapes reviewed; their existing enormous iteration loop was not executed.

Actual gpt-6.1-sol/xhigh design session 01a0ffc9-3e70-7eb2-a11c-e7c0e7dd6e7b: ACCEPT. Final review session 01a0ffdd-3e50-7a40-aafe-0dc8d39e1548: APPROVE, no verified material blocker. Exact reviewed stage diff SHA-256 46fe5e0e6e19abd6b732366c7705e55a9ba54dd6b30dfffe6596c611b9e1f16e. New-head CI is not awaited or claimed green. Refs #29249; tracking issue stays open.

@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 changed the title refactor(sql): consolidate temporal execution and orthogonal regression tests refactor(sql): consolidate active owners and retire obsolete paths Oct 2, 2026

@fengttt fengttt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you.

Refs matrixorigin#29249. Reject missing cleanup and retained-pointer mutations using existing overflow/reuse scenarios.
Refs matrixorigin#29249. Preserve 24 literal oracles and benchmark populations while removing redundant correctness work; record paired owning-package CPU, RSS and elapsed evidence.
Keep scenario assertions and production timeouts intact. Release fixture-owned
atomic blockUnlock flags after the callback and before the existing reset,
which retains generation invalidation and retained-worker joining.

Stage evidence: 74 related tests pass in normal and race execution; both
directly affected tests pass 100 individual race repetitions. Six serial
full-package normal runs pass. Median wall time 11.750s -> 9.869s; CPU
2.081s -> 2.451s and RSS 209.7MiB -> 199.9MiB on this shared host.
No CPU reduction claim.

Full-package race is NOT green: the regexp admission control failed with
an engine timeout. Clean baseline passed; direct causality is not established.
Deterministic probes separately expose idle and concurrent deadline defects
in the pinned dependency; its complete fix is follow-up work. No dependency
or production code changes are included in this stage.

Read-only gpt-6.1-sol/xhigh review APPROVE for this non-final checkpoint.
Configured incremental lint: 0 issues. MO lint: no incremental diagnostics.

Refs matrixorigin#29249

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

Diagnosis follow-up — 2026-10-03

User scope: MatrixOne only; deliver diagnosis evidence first. No dependency fork, upstream mutation, v2 upgrade, timeout relaxation or fix PR has been made.

Conclusion: a pre-existing regexp2 deadline defect is confirmed, but it has not been established as the cause of #29574's historical Linux full-package race failure. The earlier P2 is a historical validation/attribution gap, not a verified code regression introduced by this PR.

Current main and reproducibility

Verified clean main b210a0a5fc878e1e7d04c371297687de003ba292, Go 1.26.4, Darwin/arm64, platform-matched native artifacts, GOMAXPROCS=2 and GOMEMLIMIT=2GiB:

  • Complete pkg/sql/plan/function, -race -tags matrixone_test -p=1 -count=1, without -short: PASS, 19.490s.
  • Exact TestRegexp2EvaluationAdmissionRejectsUnboundedRunnerGrowth, same mode, -count=100: PASS, 3.985s.
    These are new passing evidence, not reproduction of the original Linux host/load. They do not prove that the old failure never happened or was simply “base flaky”.

Independent dependency root-cause proof

The declared pre-PR base 9078a8bd... and current main have identical regexp implementation/tests and dependency inputs: regexp2 v1.10.0.

  • On actual dependency tag v1.10.0 (03d34d8...), a white-box stopped-clock state with a stale tick and an epoch one minute earlier produces an already-expired newly requested one-second deadline. The exact assertion fails: returned tick 954 versus actual elapsed tick 57220. No scheduling sleep is the oracle.
  • v1.11.5 (bbde16d...) repairs the serial restart but fails two separate, barrier-controlled interleavings: (1) a competing caller restarts the clock while the first awaits the slow-path mutex; (2) the first samples old current before the competing caller publishes a new clockEnd.
  • Applying the complete clock correction in a private diagnostic copy makes both interleavings pass 100 race repetitions each. The independent serial idle control also passes. The correction snapshots clockEnd before current and recomputes the deadline after acquiring the mutex even when another caller already restarted the clock.
    The pause hooks live only in the disposable dependency diagnostic copy, not MatrixOne, the module cache or a delivery patch. Existing upstream test configuration uses a 1ms clock period; it was retained, not used to relax the requested deadline.

Repair boundary

The complete concurrent correction is present in upstream v2 936b3813, not the inspected v1.11.5/v1.12.0 releases. It cannot be pinned through the v1 module path. A v1-API-compatible complete backport is the proportional repair route; copying an entire dependency into MatrixOne, installing a second clock/worker or merely upgrading to the incomplete v1 fix is not justified. No external repository work is authorized for this stage.

The confirmed dependency defect and the unassigned historical package failure remain separate claims. No new MatrixOne code defect or causal #29574 regression is being asserted.


Historical review record (preceding diagnosis)

Post-merge status update: this review was started at 0a73284. During submission the PR had already merged after 93f7a8c, a merge of main fcd9686 into that same branch. Verified that the PR's production/test delta against its refreshed base is unchanged, including the lock-fixture change, regexp test/dependency and unresolved checkpoint record. The finding below is a remaining validation concern after merge, not a claim that the merged PR can still be blocked. I am not asserting that the regexp failure was introduced by this PR.

Deep review of 0a73284 against 9078a8b. Decision: NOT READY / changes required for validation closure. This is a COMMENT review because the authenticated reviewer is the PR author; it is not an APPROVE. No subagents were used.

P2 — reconcile the observed complete-function race failure before final approval. The current versioned design (Lock-fixture checkpoint review) records a candidate failure in TestRegexp2EvaluationAdmissionRejectsUnboundedRunnerGrowth: an admitted positive control returns "regexp match timed out", while the verified clean baseline full race passes. It explicitly leaves overall readiness blocked and says the independent regexp2 deadline probes do not establish causality. Thus neither "base flaky" nor "the fixture caused it" is currently proved. The proposed dependency fix is follow-up work, not a required solution: first discriminate deadline accounting, package interaction and external load, then close the actual failing invariant without widening timeouts, retries, skipping the control or adding an unrelated dependency branch.

I verified the later exact-head CI run 37098322396 is successful, including function in the resource-heavy race stage (-short -tags matrixone_test), SCA, build and multi-CN BVT. The named regexp control itself has no short-mode skip. This is valid additional passing evidence, but one successful different-mode/package-load run does not explain or close the explicitly recorded candidate-only failure under the controlled local mode. The acceptance record must reconcile both results with a concrete cause/control and final evidence; a blind rerun or a speculative clock patch is insufficient.

Design and implementation: reused the complete cumulative review at e37f979 for unchanged production closures, and read all eight subsequently changed artifacts. Temporal adapters retain existing arithmetic, metadata, selection, NULL and per-row warning owners. Literal allocation cleanup and constructor transfer are unchanged since the prior review. There is no newly added runtime state machine, cache, execution framework or persisted format. The new lock-fixture defer releases simulated atomic blockers before the existing generation/reset/join owner, including assertion/panic exits; current consumers do not install unlockResume channels. This change does not claim to fix every pre-existing detached-worker teardown limitation.

QA/test quality: DATE_FORMAT keeps the 24 independent literal pairs and six formats while replacing 4.9M repeated UT rows with 24; per-row format, NULL, mask and zero-date controls remain. The benchmark keeps its previous population and iteration policy. Constructor/account cleanup is registered before assertions; failure oracles precede fallback teardown. Zonemap tests now independently observe native bytes, Go-heap ownership and cleared scratch slots; recorded free-with-stale-pointer and outer-cleanup mutants distinguish the two invariants. No actionable historical GitHub thread remains.

Cost and scope: implementation +257/-1189, tests +1899/-3939, documents +213/0. Reported DATE_FORMAT package savings and lock-fixture wall-time improvement are bounded local measurements; lock-fixture CPU actually increases 17.8%, and no whole-CI/query performance claim is justified. The expanded evidence documents contain checkpoint history; that history is evidence, not additional production design. Historical SQL/executor/benchmark evidence remains valid for unchanged production inputs. Data compatibility is preserved; mixed-version upgrade was not treated as a requested review gate.

No additional verified code blocker was found in the follow-up. Final approval remains withheld for the unresolved failed-validation record above, rather than for speculative design preferences.

This branch was previously deployed

1 inactive deployment
ci — 93f7a8c8 Deployed Oct 3, 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/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants