Skip to content

refactor: consolidate unused code and duplicate responsibilities - #31488

Merged
XuPeng-SH merged 315 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/systematic-cleanup-batch-20261027
Oct 31, 2026
Merged

XuPeng-SH merged 315 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/systematic-cleanup-batch-20261027

Conversation

@XuPeng-SH

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

Remove unconsumed implementation and bookkeeping, consolidate repeated logic under existing owners, and simplify fixtures while retaining behavioral assertions across CDC, storage/Iceberg, SQL planning/execution, metadata and service infrastructure.

Rebase onto main 4f894474ad10 and consolidate unpublished catalog migrations under the existing 4.0.7/41 handler. Preserve the released 4.0.6/5 contract, remove the superseded 4.0.18/19 handlers and unused wrappers, and make the existing COLUMNS/STATISTICS entries publish current metadata. Reuse the existing paged upgrade, transaction and recovery owners; shutdown upgrade only. Catalog identity 4.0.7/41 must be frozen when released; incompatible unreleased-main catalog layouts are not supported upgrade sources.

Conflict resolutions preserve upstream unsigned subscription metadata, CSV EOF reset, Top batch offsets, prepared non-finite float handling, explicit constraint-name handling and upgrade-limit validation.

Scope decision: @XuPeng-SH approved this accumulated batch as a one-time exception to #29249's small-PR rule. Independent changes couple PR-level review and rollback; individual commits remain available subject to dependency validation. The ongoing issue remains open.

Prior batch validation reported before the CI test correction (Go 1.27.1, macOS arm64):

  • Native libraries and mo-service built successfully. Configured incremental formatting, vet, molint and golangci-lint passed across the final 122-package closure.
  • Full bootstrap/version tests passed normally and with -race -count=1. Six real-engine upgrade/rollback/CDC scenarios passed in both modes. Eight nonempty rebase consumer packages passed 9,301 top-level tests in each mode; the shared schema package is covered through both consumers.
  • All three tests that failed readiness in the previous CI passed locally with race instrumentation. This does not establish the cause of the historical CI failures.
  • Official v4.1.0 (catalog 4.0.1/1) and v4.2.6 (4.0.6/5) persisted data upgraded to 4.0.7/41 using the current binary. Data, FK rejection, snapshots/historical reads, DECIMAL metadata and index prefix lengths were checked. A SIGKILL during the actual 4.0.7 tenant migration recovered to one completed upgrade step with exact 1/1 tenant progress.
  • Independent gpt-6.1-terra/max design and overall review; unchanged cleanup paths reuse the qualified original review and independent merge-tree comparison. Earlier batch validation is retained externally. The new runs focus on upgrade and rebase-affected owners, not a fresh execution of every package in this batch.

The release-data checks are local single-CN Linux-to-macOS shutdown/recovery tests, not distributed or mixed-version certification. Existing upgrade scan/reconciliation costs remain; no new performance benchmark claim. New-head CI is pending. Temporary evidence and datasets are not committed.

Statistics upgrade CI correction (Linux amd64, Go 1.27.1):

The upgrade handler publishes the prefix-aware STATISTICS definition, while the integration test still counted and expected the historical definition. Align the test's replacement counter, persisted-definition assertion, and shared-view cleanup with the current definition, retaining the historical view as the upgrade input. Reuse the existing index to verify the legacy SQL NULL before upgrade, then numeric SUB_PART = 3 for the retained prefix and SQL NULL for the whole-column index after each upgrade, for both system and tenant accounts. Cleanup attempts both view restoration and database removal with independent bounded contexts. Production upgrade code and catalog version/offset are unchanged.

Validation for this test-only follow-up: four focused V407 upgrade/login/provenance tests passed normally; TestV407UpgradeRefreshesStatistics passed with atomic coverage instrumentation of versions/v4_0_7/sysview and under -race. Incremental gofmt, vet, pinned molint and configured golangci-lint 2.14.0 passed for pkg/tests/upgrade. Independent gpt-6.1-terra/max design and final review cover the follow-up and its production interactions. This reuses existing cluster fixtures and does not add a new cluster. New-head CI remains pending; these focused checks are not a fresh full-suite or distributed-upgrade certification.

@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 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 52e198b1b4673fa6eb847f060c2adac8e9feb554

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: 52e198b1b4673fa6eb847f060c2adac8e9feb554

Assessment: request_changes

Reviewed the complete 493-file delta. Focused checks passed without a confirmed runtime regression, but the batch violates linked issue #29249’s explicit requirement to separate unrelated refactors.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

  • P2 pkg/common/stopper/admission.go:25: The worker-admission consolidation ships together with independent bootstrap upgrade runners, Iceberg credential handling, SQL numeric conversions and unrelated test cleanup.
    Impact: This couples independent validation and rollback boundaries, contrary to #29249’s acceptance criteria. Split the unrelated changes into cohesive, independently verifiable PRs. This is a scope/design finding, not a demonstrated runtime defect.
    Evidence: Frozen evidence.json includes #29249’s complete acceptance criteria: keep each linked PR focused and independently revertible; do not bundle unrelated refactors. AdmissionGate and its ISCP/publication consumers do not require the changes in pkg/bootstrap/versions/upgrade_runner.go, pkg/sql/iceberg/append_runtime_factory.go or pkg/sql/plan/function/func_cast.go. The PR body acknowledges the broad batch but supplies no dependency rationale or scope exception.

Validation:

  • Isolation preflight passed; native prerequisites were built through the repository owner in an unchanged exact-head diagnostic checkout.

  • Passed full SQL function, util, container/types and Iceberg API suites; stopper race tests passed three repetitions.

  • Passed focused storage, upgrade, task-service, HLL, planner and Iceberg tests. Focused ISCP/publication and CTE lifecycle race tests passed twice.

  • Verified complete collation implementation equivalence and moved helper bodies against baseline.

  • Reconciled commands, source fingerprints, exits and retained logs in /home/xupeng/.local/state/mo-bot/jobs/4c98361c39cec585c9f550d8/attempt-1/validation-audit.json. Saved complete discussion-assessment.json; both discussion items are informational.

Limitations:

  • Frozen core CI lanes remain pending. Author-reported broad validation has no supplied local_validation artifacts and was not counted as verified execution.

  • No whole-repository runtime certification, live-cloud testing, historical upgrade matrix, multi-CN end-to-end testing or measured performance comparison is claimed.

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

Reviewed base 7e0c9d94fce444a2930c335135a3fc5860e1fe6a → head 52e198b1b4673fa6eb847f060c2adac8e9feb554. No confirmed introduced P0/P1 defect was found in the reviewed paths.

[P2] Preserve independently reviewable and revertible cleanup boundaries (pkg/bootstrap/versions/upgrade_runner.go:27, representative location). The linked issue’s acceptance criteria explicitly require small, focused PRs and prohibit bundling unrelated refactors. This 493-file delta combines historical upgrade execution, worker admission, object-storage multipart uploads, Iceberg credential resolution, decimal conversions, and unrelated test cleanup. For example, the upgrade runners have no dependency on the admission-gate extraction or the SQL decimal-cast consolidation. Delivering these together couples their validation and rollback: reverting a problematic cleanup at the PR boundary also reverts the independent cleanups. Please split these into cohesive changes with their corresponding tests, or record an explicit owner scope decision permitting this batch. This is an original acceptance-criteria finding, not a demonstrated runtime failure.

Validation: inspected the full diff and relevant callers/tests, including cancellation, buffer ownership, compatibility handlers, planner/executor policy differences, and retained regression entry points. Newly executed checks on functions extracted from the exact base/head blobs passed: 487,305 SUBSTRING_INDEX differential cases, 1,114,368 Unicode/invalid-byte fold cases, and 4,544 timezone inputs. Static comparisons confirmed identical general_ci weight tables/decoding and selected migrated helper bodies. The PR artifact check passed. These checks do not execute the full MatrixOne package suites or live-cloud/historical-upgrade scenarios.

Reused exact-head CI evidence: 30 completed checks comprise 14 success, 14 skipped, and 2 neutral, with no failures; CI Required passed. The current head remains unchanged and GitHub reports MERGEABLE with merge state BLOCKED. Review history, all current threads (0), and the PR conversation were checked: this account has no previous review, and the existing bot completion message is not a substantive author reply. With one P2 finding and no P0/P1 findings, the event is COMMENT.

@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 52e198b1b4673fa6eb847f060c2adac8e9feb554

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: 52e198b1b4673fa6eb847f060c2adac8e9feb554

Assessment: request_changes

The prior P2 scope finding remains supported. Exact-head validation is traceable and CI has passed, but neither resolves the linked issue’s explicit prohibition on bundling unrelated refactors. No new runtime defect was confirmed.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

  • P2 pkg/bootstrap/versions/upgrade_runner.go:27: This PR delivers historical upgrade consolidation together with independent worker-admission, Iceberg credential and SQL decimal-conversion refactors.
    Impact: The batch couples separate validation and rollback boundaries, violating #29249’s focused, independently revertible PR requirement. Split the changes into cohesive PRs, or record an explicit, reasoned issue-owner scope decision permitting this batch.
    Evidence: The complete frozen #29249 acceptance criteria prohibit unrelated refactor bundles. Upgrade runners, stopper.AdmissionGate and its ISCP/publication consumers, Iceberg resolveWriteObjectIOContext, and decimal conversion helpers have separate responsibilities and callers. The PR acknowledges the broad batch but provides no dependency rationale or scope exception. Both earlier reviews raise this same concern; the complete discussion contains no substantive author rebuttal. This is a scope/acceptance finding, not a demonstrated runtime failure.

Validation:

  • Verified all 493 file deltas against the frozen base/head and byte-identical prior review artifacts; reused unchanged full-delta review coverage.

  • Independently reconciled 15 retained receipts with commands, source fingerprints, exits, log hashes and native provenance. Qualified results include full SQL function/util/types/Iceberg API suites, stopper race tests and focused storage, upgrade, planner, Iceberg and worker/CTE lifecycle checks.

  • Frozen exact-head CI contains 14 successful, 14 skipped and two neutral completed checks, superseding the earlier pending-CI limitation.

  • Saved discussion-assessment.json covering all five discussion keys. Current checks/1793145899531740927-4.json and checks/1793146021198481954-4.json both exited zero; matching logs are retained-validation-audit.log and discussion-audit.log in the assigned diagnostic directory.

Limitations:

  • No Go tests were rerun for unchanged inputs. Broader author validation claims and the second reviewer’s standalone differential counts remain reported evidence; live-cloud coverage, a complete historical upgrade matrix and measured performance are not independently established.

@XuPeng-SH

XuPeng-SH commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: e41ec645c1ac63c3fd69fd80756c58a1be98c7f3

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: e41ec645c1ac63c3fd69fd80756c58a1be98c7f3

Assessment: approve

No actionable findings remain. The owner exception resolves the prior scope concern. Catalog consolidation preserves released-source migration behavior and existing recovery ownership. Qualified prior coverage for 471 unchanged edit sequences; reviewed 38 fresh deltas and relevant upstream interactions.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • Normal tests passed: 25 packages, 7,483 top-level tests; eight tests skipped and two packages contained no tests. Receipt: checks/1793410918364370885-3.json.

  • All six real-engine metadata, rollback, restart and CDC scenarios passed. Receipt: checks/1793410980851942526-3.json.

  • Bootstrap/version and stopper race tests passed: 20 packages, 279 top-level tests. Receipt: checks/1793411398821451764-3.json.

  • Verified pinned release identities, shared-schema/helper equivalence and native provenance. Complete discussion assessment saved. Final receipt/log audit passed and source remained clean: checks/1793411471733738651-4.json; validation-audit.json.

Limitations:

  • Frozen CI remains pending. Historical runtime logs and author-reported released-binary/SIGKILL evidence were not independently recovered.

  • Local engine scenarios stage older catalog shapes on the current engine. No full-repository, multi-CN, GPU, live-cloud or performance certification is claimed.

@XuPeng-SH

XuPeng-SH commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor Author

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

Commit: 3b7c384d0fab76555817c852c0ab42c61d4a3099

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: 3b7c384d0fab76555817c852c0ab42c61d4a3099

Assessment: approve

No actionable findings remain. Qualified prior coverage for the unchanged cleanup and independently reviewed the STATISTICS test correction. It preserves existing assertions, adds independent prefix-length checks, and improves cleanup. The prior scope concern remains resolved.

Model: gpt-6-astra / xhigh

Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2

Validation:

  • Four focused integration tests passed with atomic coverage; receipt checks/1793415967913542666-3.json.

  • TestV407UpgradeRefreshesStatistics passed under race instrumentation, including system and tenant cases; receipt checks/1793416231304600814-3.json.

  • Reconciled ten retained receipts and matching logs, qualifying prior normal suites, six engine scenarios and bootstrap/stopper race suites. Details: reused-evidence-audit.json.

  • Final audit passed: all 13 discussion keys covered, native provenance verified, source unchanged. Receipt checks/1793416261220945283-4.json; validation-audit.json.

Limitations:

  • Frozen CI remains pending. Author-reported released-binary and SIGKILL checks were not independently recovered.

  • Fresh integration checks use a single-CN current-engine fixture; no full-repository, multi-CN, GPU, live-cloud or performance certification is claimed.

@XuPeng-SH
XuPeng-SH merged commit 3f484ec into matrixorigin:main Oct 31, 2026
@XuPeng-SH
XuPeng-SH deleted the codex/systematic-cleanup-batch-20261027 branch October 31, 2026 04:02
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Oct 31, 2026
….7 tail (r105)

Upstream matrixorigin#31488 deleted the unpublished 4.0.8-4.0.19 handler packages
and consolidated every unpublished migration into the unpublished 4.0.7
handler, whose contract (docs/design/20261028-catalog-upgrade-407.md)
forbids registering those identities as upgrade steps. The two
data-branch provenance catalog creations therefore land as the tail
tenant entries of v4_0_7 (offset 41 -> 43).

r105 records the placement re-derivation in sections 3, 7 and 10 and in
the D149 register note, and records the incompatible-unreleased-layout
rejection for main-era clusters stamped 4.0.7 at offset 41. Editorial
only: no protocol, invariant, or decision change; the r100 approval of
record stands, as it did for the r103/r104 editorial hops.
XuPeng-SH pushed a commit that referenced this pull request Oct 31, 2026
…L and branch merge (#31945)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to #30359.
Related to #30360.
Related to #30679.
Related to #30896.

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

### Problem and root causes

Every generated sequence value must come from the intended sequence's
state. Four independent paths violated that contract:

1. **DATA BRANCH MERGE leaves the destination sequence behind.** Merge
applies branch rows through an explicit writable-column `INSERT ...
SELECT`, materializing the branch's key values, so the destination
table's `DEFAULT nextval(...)` never runs and its sequence never
advances. The next ordinary `INSERT` then duplicates a merged key
(`ERROR 1062: Duplicate entry '2' for key 'id'`). Root cause: no
sequence reconciliation in the merge apply path.
2. **Qualified INSERT resolves the default sequence in the caller
database.** For `INSERT INTO owner_db.t` with another database current,
a column default `nextval('s')` resolved and advanced the caller
database's same-named sequence instead of the one owned by `owner_db.t`.
Root cause: the table-default expression binder used the session
database rather than the table owner database.
3. **ALTER SEQUENCE ... START WITH is lost across sessions.** Only the
called flag persisted; the restart/clamp decision was not committed and
`createsql` was not replayable, so a fresh session observed stale state
or reissued consumed values. Root cause: the ALTER path never persisted
the new start-with state nor updated the stored definition.
4. **Rolled-back NEXTVAL values were reissued.** Sequence advancement
participated in the user transaction, so `NEXTVAL` inside a rolled-back
transaction re-issued the same value later. Root cause: no obligation
tracking of issued values across rollback.

### What this PR does

- **Post-merge sequence reconciliation** (new
`pkg/frontend/data_branch_sequence_reconcile.go`): after a successful
table merge, the destination table's owning sequence advances to just
beyond the merged keys. The reconciliation is monotonic,
increment-quantized, direction-aware (ascending and descending) and
storage-domain-aware across all six integer domains; merged
out-of-domain explicit keys do not corrupt the watermark; exhaustion of
a NO CYCLE sequence fails the merge atomically. The reconcile commits as
its own unit, so a later merge rollback consumes a gap but never reuses
a value.
- **Owner-database default binding** (`pkg/sql/plan/build_util.go`,
`bind_insert.go`, `bind_multi_insert.go`, `bind_replace.go`,
`bind_update.go`, `build_load.go`, `build_constraint_util.go`, iceberg
DML paths, `pkg/sql/plan/function/seqfunc.go`): a column default
`nextval(name)` on `owner_db.t` always resolves and advances the
sequence in `owner_db`, for BIGINT and cast-wrapped column types;
auto-commit and explicit transactions and multi-row inserts behave
identically; a missing owner sequence raises sequence-not-found and the
caller database's same-named sequence is never consulted.
- **Persisted ALTER state** (`pkg/sql/compile/ddl.go`,
`sequence_state.go`, `pkg/sql/plan/build_ddl.go`,
`ddl_expression_replay.go`): `ALTER SEQUENCE ... START WITH` commits a
direction-aware restart (strictly ahead of the current position/pending
value restarts to exactly that value; at-or-behind clamps and the
position continues), for called and never-issued sequences alike, with
bounds validation and no partial change; the stored definition is
updated so SHOW CREATE/catalog consumers see replayable metadata; a
fresh session observes the same effective state and never reissues
consumed values.
- **Rollback obligations + autonomous allocation machine**
(`pkg/vm/process/sequence_obligation.go`, `sequence_retry.go`,
`pkg/sql/plan/function/seqfunc_autonomous.go`,
`sequence_retry_probe.go`, `pkg/frontend/sequence_commit.go`): issued
values that roll back are recorded and never reissued (gaps allowed);
allocation runs in an autonomous transaction with a progress-renewed
retry window bounded at min(statement deadline, 10 s), probe-first
expiry arbitration (renew/retire/resolve-naming), bounded per-attempt
contexts propagated into every engine metadata read, and an exactly-once
named terminal error when contention shows no committed progress for a
full renewal interval while the row stays held. ROLLBACK always
succeeds; explicit-transaction writers get conflict errors without
transparent retry.
- **Attempt-output lifecycle** (`pkg/vm/process/types.go`,
`pkg/sql/compile/compile2.go`, `pkg/frontend/session.go`,
`query_result.go`, `select_into_user_variables.go`, `status_stmt.go`,
`mysql_cmd_executor.go`, `resp_client.go`): before a transparent retry
replays an unpublished auto-commit statement, every retained output
consumer is discarded after producer quiescence — prepared-cursor
staging, `SELECT ... INTO @var` capture (reset so a one-row retry
assigns the retried row instead of `ErrTooManyRows`), and PERFORM
saved-result blocks/accounting (statement metadata preserved). The
discard callback returns cleanup errors: a failure aborts the retry
instead of replaying over surviving output, and failed cleanups keep
their owner so terminal statement cleanup still reaches the files.

### Validation

BVT (mo-tester, isolated 2-CN cluster; all pass, failed: 0):

-
`test/distributed/cases/git4data/branch/merge/merge_sequence_reconcile.sql`
(272 statements: unit/non-unit increments, signed/unsigned storage
domains, merge-rollback gap semantics, duplicate-key retry, case
sensitivity, transformed defaults, decimal-backed NEXTVAL defaults)
- `test/distributed/cases/sequence/alter_sequence_start_with.sql` (139),
`qualified_insert_owner_db.sql` (27), `nextval_rollback.sql` (58),
`sequence_txn_local.sql` (164)
- Existing `alter_sequence*.result`, `clone_database_sequence.result`,
`issue_28246.result` updated for the intended persisted-ALTER semantics;
all other sequence BVTs unchanged and green.

UT (Go, focused + full package, including `-race`; all green):

- `go test ./pkg/frontend/ ./pkg/sql/compile/ ./pkg/sql/plan/
./pkg/sql/plan/function/ ./pkg/vm/process/` and the same under `-race`,
zero data races.
- New regressions: merge-reconcile ownership/barrier tests,
owner-database binding tests, persisted-ALTER cross-session tests,
obligation/rollback tests, autonomous-machine context-bounding and
expiry-arbitration tests, `Compile.Run` retry regressions (discard
invoked on transition, retained consumers reset, cleanup error prevents
replay), select-into reset and PERFORM abort tests, deletion-failure
owner-retention test. Each was shown failing on the pre-fix base and
passing after the fix.

Live controls: 16-client two-CN storm issued exactly the unique values
1..16 (next 17); designed contention produced exactly-once named
terminals (8/8); insertion throughput unchanged within noise.

Rebase validation (2026-10-31, head `2972d080d8` on main `dd762803d1`):
conflict resolution adopted upstream #31488's `maps.Clone` consolidation
in `pkg/sql/compile/sequence_state.go` (this change's
`arbitrateSequenceRetryAdmission` and the CTAS obligation handoff kept)
and carried the owner-database parameter into upstream `#30316`
float-default test call sites. `go build` and `go vet` clean for
`pkg/vm/process`, `pkg/sql/plan`, `pkg/sql/plan/function`,
`pkg/sql/compile`, `pkg/frontend`; full `go test -count=1` suites green
on all five packages (process 2.9s, plan/function 32.2s, plan 96.6s,
compile 23.6s, frontend 37.3s), including the reconciled float-default
tests.

SCA fix (2026-10-31, head `e07dc8a214`): the arm64 SCA job failed `make
err-check` because this change introduced the raw
`fmt.Errorf`/`errors.New` forms the Makefile gate forbids
(`pkg/vm/process/sequence_retry.go:37`, `sequence_retry.go:32`,
`sequence_retry_probe.go:54`, `seqfunc_autonomous.go:55` and `:472`).
The three sentinel errors are now `moerr.NewInternalErrorNoCtx` values;
`SeqProbeIdentityGoneError` composes the identity detail through a small
wrapper type whose `Unwrap` preserves the pinned `errors.Is` semantics
(moerr `Error.Is` matches only context codes), and the exhaustion
fallback cause uses moerr as well. No message contract changed: existing
assertions key on `errors.Is` and the unchanged "allocation could not
acquire" prefix. Local gates: `make err-check` clean; `golangci-lint run
-c .golangci.yml` and `molint check` on `pkg/vm/process`,
`pkg/sql/plan`, `pkg/frontend`, `pkg/sql/compile` both 0 issues; `go
build` clean; `go test -count=1` green: `pkg/vm/process` 2.6s,
`pkg/sql/plan/function` 36.8s.

### Residual risks / limitations

- Gap-free issuance is not guaranteed across rollbacks, retries or merge
resolutions; uniqueness and monotonicity beyond merged keys are the
contract.
- An aborted or rolled-back merge may consume a destination-sequence
gap; merged rows are fully removed.
- Reconcile applies to the table's default-referenced sequence;
standalone sequences still need explicit setval/alter management.
- Transparent statement retry applies only to auto-commit statements
before any result delivery; explicit transactions keep conflict errors.
- Pre-existing, unrelated: on a two-CN layout, objects of a freshly
`DATA BRANCH CREATE`-d database are invisible to the second CN (`ERROR
20405`); reproduces identically on the base binary without this change
and will be tracked separately.
- Design record (independent review approved; revision v22 carries the
approved v21 contract plus the v22 conformance correction):
`docs/design/sequence_ownership_state_consistency.md`.

UT coverage re-pin (2026-10-31, head `17b58d0a87`): the `Matrixone UT
Coverage execution / UT Coverage on Ubuntu/x86` job failed only
`pkg/tests/issues.TestIssue28246ConcurrentNextval` (runs 41189758357 job
124504310648 and, identically, pre-SCA head `bae81d4ee1` run 41182286055
job 124482041630). The upstream Go oracle still pinned the pre-fix
semantics this change deliberately replaces (design doc §1 Defect D, §2
I4, §8 deliberate pin updates): `2_sessions`/`4_sessions` asserted a
rolled-back NEXTVAL releases its value (expected `workers+1`, observed
`workers+2`), and `controlled lock handoff`/`lock wait timeout` required
NEXTVAL to queue on the holder's sequence row lock and fail with `Lock
wait timeout exceeded` — while autonomous allocation on a committed
generation holds no caller-transaction lock at all. The Go oracle is
re-pinned to the reviewed contract: a rolled-back allocation stays
consumed with the persisted counter advanced; a waiter receives the next
value while the holder's transaction is still open; `lock_wait_timeout`
no longer gates NEXTVAL; a fresh session never re-issues a rolled-back
value; connections remain usable. This mirrors the BVT
`issue_28246.result` pin update already in this change, extended to the
Go oracle the §8 inventory missed. Local: `go test -count=1 -run
TestIssue28246ConcurrentNextval -v ./pkg/tests/issues` green (9.2s
concurrent-nextval suite + 6.6s placement suite), `go vet` clean.


Post-PR review fix (2026-10-31, head `43b8c25057`): the post-merge
review confirmed one incomplete fix — merging DECIMAL-backed NEXTVAL
defaults (DECIMAL(18,0), DECIMAL(18,2), DECIMAL(38,0) primary keys with
`DEFAULT nextval(...)`) left the destination sequence behind, so the
next default INSERT regenerated a merged key (`ERROR 1062: Duplicate
entry '2'` / `'2.00'`; BIGINT control passed). Root cause:
`extractDataBranchSQLRowValue` preserves typed `Decimal64/128/256`
apply-row values, while the merge watermark capture accepted only
machine-integer types and numeric strings/bytes, so typed decimals were
silently skipped. The capture now normalizes integral typed decimals by
the destination column's scale (stored keys are unscaled `key * 10^s`;
decimal128/256 divide through limb-wise divisors) and folds the integral
quotient into the unchanged int64/uint64 domain arms; stored fractions
and quotients at or above 2^64 stay skipped, like other foreign values.
Design doc revised to v22 (DEC1; §4 B). Validation: pre-fix code pinned
skipping typed decimals (temporary unit assertion, later removed) and
the pre-fix build reproduced the reviewer's duplicate-key probe on an
isolated cluster; post-fix `go vet` clean, the full `pkg/frontend`
reconcile suites green (20 top-level test functions including the
16-case decimal truth table + monotonic accumulation), and the same live
probe advances every decimal watermark 1→2 with post-merge default
INSERTs allocating 3 (final counters 3; full
`merge_sequence_reconcile.sql` executed live with only its two pinned
expected errors).

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
cpegeric added a commit to cpegeric/matrixone that referenced this pull request Nov 1, 2026
Conflicts and merge fixes:
- function ids: main took 624..628 for EWM_*; VECTOR_MATMUL, VECBLOCK_JSON and
  VECBLOCK_BINARY move to 629..631 (FUNCTION_END_NUMBER 632), and
  aggexec.AggIdOfVectorMatmul to 629 << 32
- mysql_sql.go regenerated with goyacc from the merged grammar
- strhashmap.go: both sides kept; the new fixed-key fast path copies
  bf16/float16/float8/float4 bytes (zeros are stored as +0)
- pkg/iscp: copyBytes was removed by matrixorigin#31488; vecf8/vecf4 use CloneBytesAt
- TestTypeSwitchFamilies: the EWM window functions take bf16/float16/
  float8/float4 samples, decay, policy arguments and event-time ORDER BY
  keys; parallel UNION ALL projection admits them as IFF conditions; the
  two plan.Literal readers are tagged partial
- vector_distance_semantics.result: the vecf16 overflow message follows
  this branch's out-of-range error
- lowprec_ddl_dml: EWM over the low-precision floats against FLOAT

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Nov 2, 2026
…e to txnTable refactor

Upstream main advanced 41 commits past the previous merge base
4183159; its matrixorigin#31978 (exclusive SELECT lock authorization) added
Query.select_lock_references (field 21) and message SelectLockReference
to proto/plan.proto and regenerated pkg/pb/plan/plan.pb.go, colliding
with this branch's regenerated bindings (Node.scan_read_role = 97, enum
ScanReadRole, IndexScanInfo.parent_table_id = 7, LockTarget additions).

Resolution:
- plan.pb.go: take the auto-merged plan.proto (additive on both sides,
  no field-number collision: this branch's fields are 97/7/20, main's
  are 21 and the new SelectLockReference message) and regenerate the
  bindings with the repository's verified protoc/gogofast toolchain plus
  the plan_string_literal_form and plan_collation_admission
  postprocessors. The regenerated bindings equal main's HEAD plus
  exactly this PR's additive identifiers; verified by bidirectional
  diff with no deletions of either side's code.
- disttae: upstream matrixorigin#31488 removed the write-only txnTable field
  clusterByIdx from the struct while this branch's
  cloneForExecutionRead literal and the execution_read_test constructor
  still referenced it. Follow upstream's structure: drop the two dead
  references. All remaining clone fields exist in the merged struct,
  and deepcopy/base_binder/query_builder deltas of both sides survive
  verbatim.

Validation: full-tree go build ./pkg/... and the 9-arm focused ladder
(green-{compile,lockop,disttae,plan,txnclient,moerr,issue30955,
enginetest,frontend-combined}) plus go vet green on the merged tree.
fengttt added a commit that referenced this pull request Nov 4, 2026
…vecf4 vector columns (#20567) (#29554)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

Related to #20567.

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

Introduce scalar `bf16`, `float16`, `float8` (E4M3), `float4` (E2M1),
and block-scaled vector columns `vecf8(N)` / `vecf4(N)`, with shared
codecs, float32 expression promotion, casts, comparison, storage,
import/export and MySQL transport. Existing key/domain restrictions and
canonical finite-value contracts remain enforced. `VECTOR_MATMUL`
retains bounded configuration/accounting, state merging and CPU
execution; GPU execution keeps its documented numerical and
device-admission limits.

Designs: `docs/design/20260929-low-precision-scalar-floats.md` and
`docs/design/20260930-low-precision-vector-storage.md`. SQL reference
for the vector types: `docs/sql/vector-distance-functions.md`.

### Rebase and review corrections

Rebased the exact cumulative feature tree onto main
`3c07fac240311d6f2b706674614ed6034e97ff79`. The original 159 commits,
including 32 merges, are preserved in an archive ref and exact
raw-object manifest; author attribution is retained in the snapshot
commit. All 48 overlapping paths and nine conflicts were reconciled;
main-only files are preserved.

- Narrow scalar `RowToString` now formats widened numeric values, rather
than integer backing codes. This repairs checkpoint SQL-LOAD CSV round
trips (for example, `1.5` must remain `1.5`). Normal/constant/NULL
handling uses the shared vector owner; raw serialization and ordinary
scalar cases are unchanged.
- Block-scaled ODKU keeps byte-identical comparison fast, then uses the
existing decoded-value comparator. Differently encoded equal cells
remain no-ops: no unnecessary write, changed-row count or implicit ON
UPDATE change. UPDATE's changed-row predicate (also the guard for
automatic ON UPDATE expressions) compares vecf8/vecf4 cells with `<=>`
directly, without casting both sides to vecf32.
- `ALTER TABLE ... ADD COLUMN c <bf16|float16|float8|float4> NOT NULL`
without a `DEFAULT` backfills existing rows with `0`, as `FLOAT` does
(COPY and default algorithms); the implicit NOT NULL value previously
fell through to `null`.
- Main's mixed JSON/numeric comparison covers bf16/float16/float8/float4
as it covers `FLOAT`: a JSON number is rounded and range-checked as CAST
to the type does it, and a JSON string, object or array never equals a
number (`'"1.5"'` is not `1.5`). Before this, JSON compared with these
types kept the old cast-to-float path.
- Where `FLOAT` works, bf16/float16/float8/float4 now behave the same
(found by running each SQL feature on `FLOAT` and on the new types): a
user variable holding one of these values computes in DOUBLE; a constant
expression compared with the column (`a = ABS(-0.1)`) is folded and
rounded as a literal is; hex and bit literals are unsigned integers;
JSON, YEAR and ENUM cast as they cast to `FLOAT`; text that is not a
number converts to its numeric prefix with `FLOAT`'s warning in MySQL
mode (values outside the type's finite range still error); `SERIAL`
encodes the stored bits in tuple elements of their own type, ordered as
the values, and `SERIAL_EXTRACT` returns them;
`INFORMATION_SCHEMA.COLUMNS.NUMERIC_PRECISION` is the significand bits
(8/11/4/2).
- `TestTypeSwitchFamilies` also checks `==`/`!=` chains and
`[]types.T`/`map[types.T]` literals that name part of a type family; the
existing sites were reviewed and baselined.
- An empty string or empty `BLOB` is not a vector: a cast, `INSERT …
VALUES`, `INSERT … SELECT`, a prepared parameter or an `UPDATE` with it
is an error for every vector type, as `''` is for an `INT` column
(before, `vecf32` errored on `VALUES ('')` but stored NULL for `INSERT …
SELECT ''` and a prepared `''`; vecf8/vecf4 stored NULL on every path).
NULL stays NULL; `LOAD` still reads an empty field as NULL.
- Upgrade and function identities: MatrixOne upgrades by full-cluster
shutdown only
(`.agents/skills/mo-dev/references/upgrade-compatibility.md`, main
#31287), so the types and functions take no MORPC version and no
capability gate; the branch's earlier low-precision protocol gate
(remote placement, execution-stream confirmation, persisted-expression
floor, column-authoring fence) is removed, and main's existing gates are
unchanged. The types are additive persisted state: data written before
them reads as before (merges `0bf7ad2bf8`, `3b5ebd55d3`, `0bce000fa2`,
`334d14ae91`, `8841673f3e`, `64573711a1`, `ba4f725d19`, `4d5938c30a`,
`56ac42ed39`, `9cf7b69221`, `1543470717`, `9a51b315ec` and `6943941198`,
main `24c1ac897b`). VECTOR_MATMUL, VECBLOCK_JSON and VECBLOCK_BINARY
take the next free function ids after main's, and
`aggexec.AggIdOfVectorMatmul` follows VECTOR_MATMUL; main's function ids
are unchanged, and only the end marker advances. Main's TIMESTAMPADD
SECOND float switch is tagged `typeswitch:partial`:
bf16/float16/float8/float4 counts widen to float32 at resolution. Main's
in-memory sort-key filter switch (`encodeMemSortKeySpecs`) is tagged
`typeswitch:partial`: the four types are rejected as primary and cluster
keys. Main's quantileExactWeighted casts these arguments to FLOAT when
it resolves, so its switches are tagged; main's indicator window kernels
and local ranks read them as float32, which holds them exactly, and
return what FLOAT returns. Text converts as main's FLOAT conversion
(#31191) does: radix text is its integer value, other text its decimal
prefix (`'inf'`/`'nan'` are 0), and truncated text in a strict
INSERT/UPDATE is an error. Main now escapes every CSV export value in
`formatOutputString`; the vecf8/vecf4 export case passes the raw text
instead of escaping it a second time. Main moved the AVX-512 metric
loops into `//go:noinline` helpers; the branch's VZEROUPPER clear
(`archsimd.ClearAVXUpperBits`) is in each helper.
- VECTOR_MATMUL compaction and merge sort one `q` × `topk` index array,
allocated through the aggregate's allocation account and counted by
`Size`, instead of maps on the Go heap (review P2). Merge preflight
allocates that array for every merge target, so a merge that passes
preflight cannot fail on it in `BatchMerge` (review P2).
- The tuple decoder decodes a bf16/float16/float8/float4 zero of either
sign as +0 and rejects NaN and infinite elements, so SERIAL_EXTRACT of a
hand-built tuple cannot store -0 or NaN (review P2).
- VECTOR_MATMUL fill and flush stay inside the allocation account: a
string id is offered from the input vector and a numeric or UUID id from
a fixed 36-byte buffer, the CPU scorer reuses one operand per executor,
and Flush writes each group's ByteJson straight into the accounted
result vector (no JSON text, no reparse) with one accounted `topk` sort
scratch; its configuration parse is admitted before it allocates (the
account is attached first and a non-allocating bound reserved); a
fractional or exponent-form distance is encoded without the integer
parsers' error allocation (review P2).
- Exact block-cell text keeps a stored negative-zero element:
`vecblock_json` prints `-0`, and parsing it now restores the
negative-zero code (E4M3 `0x80`, E2M1 `0x08`) instead of code 0, so
export/reload no longer changes cell bytes. JSONL `LOAD` writes an
object value back with its original number lexemes, so a `-0` element
reloads to its negative-zero code in both the object and array formats.
The quantizing encoder still stores a computed zero as code 0. A number
in the exact text must denote its float32 value without rounding (the
exact value, or its shortest float32 or float64 text, in any notation);
`1.00000001`, which float32 parsing rounds to `1`, is rejected.
- bf16/float16 range: a value just above the largest finite value
(`65505` for float16) is out of range although it rounds back to the
maximum. Casts and writes reject it and comparisons with it stay wide;
the same applies to the vecbf16/vecf16 text parser, the vector narrowing
cast and `VECTOR_MATMUL` queries. A bf16 text or wider source is checked
by its float32 value, so the printed maximum `3.3895314e+38` loads back.
Comparison narrowing of a literal or prepared parameter uses the same
admission rule as CAST, so that printed maximum also narrows and matches
the row it was inserted as. Narrowing applies only when the other
operand is a low-precision column, for literals and prepared parameters
alike (`CAST(1.1 AS FLOAT4) = 1.1` and `= ?` both compare wide), and a
decimal literal of any width, including a numeral beyond `DECIMAL(38)`,
narrows by its exact value.
- `VECTOR_MATMUL` rejects a JSON `null` query coordinate or query
(`query i: coordinate j is null`) instead of reading it as 0, for every
supported column type. A supplied options argument that is empty text or
`NULL` (including a NULL user variable) is an error rather than the
defaults, and a `NULL` queries argument is an error; an omitted options
argument still selects the defaults.
- Main's exponentially weighted window statistics
(`ewmMean`/`ewmVar`/`ewmStd`/`ewmCov`/`ewmCorr`, #31941) take
bf16/float16/float8/float4 samples, alpha/half-life, policy arguments
and event-time `ORDER BY` keys as they take `FLOAT`, and return what
`FLOAT` returns; main's parallel UNION ALL projection admits these types
as IFF conditions as `IffConditionTruthyAt` reads them. Main's new
fixed-key hash fast path copies their bytes: a zero of either sign is
stored as +0, so the bytes are the key. The two EWM switches that read
`plan.Literal` are tagged `typeswitch:partial` (no literal carries these
types). Main #31488 removed `pkg/iscp` `copyBytes`; the vecf8/vecf4 row
extraction uses `CloneBytesAt` as main's other cases do (merge
`cd4d31b4f3`).
- `docs/sql/vector-distance-functions.md` (main #31896) covers
vecf8/vecf4: the block layout and quantization, the argument types each
distance pairs with (vecf8, vecf4, vecf32, vecf64; not the other narrow
types), precision (rounded into the float32 domain except
`l2_distance_sq`), the dimension-mismatch error, every function's result
type (`subvector`/`abs`/arithmetic return vecf32, `sqrt` vecf64,
`normalize_l2` and the copying functions the argument's type), the
accepted casts (text, vecf32, vecf8↔vecf4),
`vecblock_json`/`vecblock_binary`, and that no index or key accepts the
types. Each statement has a line in
`cases/vector/vector_distance_semantics.sql`; the CAGRA/IVF-PQ
rejections are in `gpu_cases/vector/vector_distance_semantics_gpu.sql`
(`0b32a9a9f0`).
- Shared authoring, feature collection, placement, destination, actual
execution stream and receiver checks compose requirements with `max`.
Main's charset migration, COPY strict assignment, diagnostics/folding
and prepared exact-source behavior are retained. The 16-byte Type layout
and existing protobuf fields are unchanged.

### Validation

- Local CPU native compilation succeeds through the repository
provenance owner; verified thirdparty artifacts were copied into
task-owned storage, then CGo rebuilt once.
- Focused normal checks pass (9 roots/119 including subtests), along
with complete types/vector/keycodec/metric/aggexec owner coverage (1,289
roots/5,555 nodes; the previously covered RowToString test is reused).
- Selected integration checks pass across 30 CPU packages (147 roots/569
nodes), including export/LOAD, parser/planner/prepared binding,
storage/WAL/zonemap and actual SQL ODKU behavior.
- One race pass succeeds for the five owners and the integration closure
(155 integration roots/682 nodes). Two allocation-measurement tests
intentionally skip under race; their normal-mode passes are retained.
- Configured incremental SCA covers 45 CPU packages derived from the
delivery diff and build constraints; golangci-lint2.14 reports zero
issues. The only new molint advisory, an unsafe import used for a size
calculation, is removed using standard type metadata at configuration
construction. Existing VECTOR_MATMUL tests pass normally and with race
after cleanup; owning-package SCA again reports zero issues. The
remaining 47 advisory locations map to unchanged base code.
- Parser reproduction, function-identity/main-only preservation,
Type-layout comparison, formatting and diff checks pass. Generated
metric-kernel consistency is exercised by owner tests.
- Required gpt-6.1-sol/xhigh design, complete review and final cleanup
review pass. Commands, fingerprints, terminal receipts and model session
IDs are retained in the task record. Go1.27.1/darwin-arm64, repository
CGo runner.

The fixes add no new retained state, locks or execution framework. The
size query runs only during block-scaled matmul configuration; decoded
equality's extra linear work is limited to differently encoded block
vectors. Ordinary scalar DML paths retain their previous code.

Author run at `e9fc0a159e` (after merging main `e033d4a587`, GPU build):
every `pkg/` test package compiles; the affected Go packages and
`TestTypeSwitchFamilies` pass; golangci-lint v2.14.0 reports no issues
in the changed packages; BVT `-m run` 0 failures: `cases/dtype` 8856 (32
ignored), `cases/array` 1501/1501, `cases/vector` 3460 (2 ignored),
`cases/load_data` 1607 (5 ignored), `cases/function` 22490 (150
ignored), `gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `eebad1d1ac` (merge-preflight fix, GPU build):
`pkg/sql/colexec/aggexec` and `pkg/sql/colexec/group` pass; the new and
related tests pass `-race -count=20`; golangci-lint reports no issues;
BVT `-m run` 0 failures: `cases/vector/vector_matmul.sql` 109/109,
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `6943941198` (after merging main `24c1ac897b`, clean GPU
rebuild): `TestTemporaryTablePhysicalNameIsSessionScoped` 5/5 (the CI
failure on `eebad1d1ac` was the ISCP fixture race main fixed in #31288),
`TestTypeSwitchFamilies`, `pkg/container/types`,
`pkg/sql/plan/function`, `pkg/sql/colexec/aggexec` and
`pkg/sql/colexec/group` pass; every `pkg/` test package compiles; BVT
`-m run` 0 failures: `cases/dtype` 8856 (32 ignored), `cases/array`
1501/1501, `cases/vector` 3460 (2 ignored), `cases/load_data` 1607 (5
ignored), `cases/function` 22490 (150 ignored),
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `64b29a2034` (tuple-decoder fix, GPU build):
`pkg/container/types` (with `TestTypeSwitchFamilies`),
`pkg/sql/plan/function` and `pkg/sql/colexec/...` pass; golangci-lint
reports no issues; BVT `-m run` 0 failures: `cases/dtype` 8871 (32
ignored), `cases/function` 22490 (150 ignored).

Author run at `c22e8a35d4` (aggregate memory audit, GPU build):
`pkg/sql/colexec/aggexec` (with and without the `gpu` tag) and
`pkg/sql/colexec/group` pass; the new and accounted fill/merge tests
pass `-race -count=10`; golangci-lint reports no issues; BVT `-m run` 0
failures: `cases/vector/vector_matmul.sql` 109/109,
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71, `cases/vector` 3460 (2
ignored), `cases/array` 1501/1501.

Author run at `c6480649e5` (fractional-distance flush allocation):
`pkg/sql/colexec/aggexec` (with and without the `gpu` tag, and under
`-race`) and `pkg/sql/colexec/group` pass; the flush allocation tests
pass `-race -count=10`; golangci-lint reports no issues; BVT `-m run` 0
failures: `cases/vector/vector_matmul.sql` 109/109,
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71, `cases/vector` 3460 (2
ignored).

Author run at `af8bbc4f60` (merge of main `802376360c`, no conflicts;
function ids unchanged): `pkg/container/types` (incl.
`TestTypeSwitchFamilies`), `pkg/sql/plan/function`, `pkg/sql/plan`,
`pkg/sql/colexec/aggexec`, `pkg/sql/colexec/group` and
`pkg/vectorindex/hnsw/...` pass; BVT `-m run` 0 failures: `cases/dtype`
8895 (32 ignored), `cases/function` 22527 (150 ignored), `cases/vector`
3499 (2 ignored), `gpu_cases/vector/vector_matmul_gpu.sql` 71/71,
`pessimistic_transaction/vector/vector_hnsw_delete_insert.sql` 56/56 ×3.

Author run at `eead4d0574` (merge of main `d4ffbae43d`; `mysql_sql.go`
regenerated from the merged `mysql_sql.y`, 0 grammar conflicts; function
ids unchanged): `pkg/container/types` (incl. `TestTypeSwitchFamilies`),
`pkg/sql/plan`, `pkg/sql/plan/function`, `pkg/sql/colexec/aggexec` and
`pkg/sql/parsers/...` pass; BVT `-m run` 0 failures: `cases/dtype` 8895
(32 ignored), `cases/function` 22550 (150 ignored), `cases/vector` 3499
(2 ignored), `cases/dml/insert` 3090 (22 ignored), `cases/load_data`
1609 (5 ignored),
`pessimistic_transaction/vector/vector_hnsw_delete_insert.sql` 58/58,
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `d57e5e560d` (SERIAL_EXTRACT validates vecf8/vecf4 cells,
review P2): `pkg/sql/plan/function` and `pkg/container/types` pass;
`TestSerialExtractBlockScaledCell` fails on all 12 invalid-input
subtests without the check; golangci-lint reports no issues; BVT `-m
run` 0 failures: `cases/dtype` 8906 (32 ignored; `dtype/vecblock.sql`
253/253 twice), `cases/function` 22550 (150 ignored), `cases/vector`
3499 (2 ignored).

Author run at `4ecd752f61` (merges of main `1fd12d526e` and
`7e0c9d94fc`; `array_str.go` conflict resolved keeping exact bf16/f16
element rounding with main's context-aware errors; `mysql_sql.go`
regenerated with goyacc, 0 conflicts; `7b55465b2c` classifies the new
types in main's sort-rollup type switch, with a ROLLUP BVT under
`SORT`/`HASH`/`COST`): `pkg/container/types` (incl.
`TestTypeSwitchFamilies`), `pkg/sql/plan`, `pkg/sql/plan/function`,
`pkg/sql/colexec/aggexec`, `pkg/vectorindex/...` (metric also with
`GOEXPERIMENT=simd`) and `pkg/sql/parsers/...` pass; BVT `-m run` on a
fresh data dir: `cases/dtype` 8916 (32 ignored), `cases/function` 22597
(150 ignored), `cases/vector` 3498 + 1 flake (2 ignored;
`vector_ivf_membership.sql` row 163 read `table_stats` right after
`mo_ctl` flush, 160/160 on 3 reruns), `cases/array` 1501, `cases/hint`
662, `cases/load_data` 1609 (5 ignored), `cases/fulltext` 1978 (3
ignored), `cases/auto_increment` 924, `cases/ddl` 8825 (168 ignored).

Author run at `410761af13` (merge of main `23488e1eb2`: conflicts in
`export.go`, `func_builtin_jq.go`, `func_cast_test.go` resolved onto
main's new helpers, `mysql_sql.go` regenerated with goyacc, usearch
rebuilt for main's new tarball; `a3a9dbf506` classifies the new types in
seven new main type switches (float text formatting counts the
low-precision types; six tagged partial with reasons); `410761af13`
follows main's MySQL float text in the low-precision BVTs, matching
`FLOAT`/`DOUBLE`/`vecf32`, and checks the bf16 maximum's new six-digit
text loads back): `pkg/container/types` (incl.
`TestTypeSwitchFamilies`), `pkg/sql/plan`, `pkg/sql/plan/function`,
`pkg/sql/colexec/{aggexec,window,table_function,external}`,
`pkg/vectorindex/...` (metric also with `GOEXPERIMENT=simd`) and
`pkg/sql/parsers/...` pass; golangci-lint reports no issues; BVT `-m
run` on a fresh data dir: `cases/dtype` 8916 (32 ignored;
`lowprec_float.sql` 431/431, `vecblock.sql` 253/253 after the text
update), `cases/function` 22669 (150 ignored), `cases/vector` 3496 + 3
flakes (2 ignored; `vector_ivf_membership.sql` `table_stats` right after
`mo_ctl` flush, 160/160 on 3 reruns), `cases/array` 1501, `cases/hint`
671, `cases/load_data` 1609 (5 ignored), `cases/fulltext` 2009 (3
ignored), `cases/window` 2792 (7 ignored), `cases/auto_increment` 924,
`cases/ddl` 8825 (168 ignored), `gpu_cases/vector/vector_matmul_gpu.sql`
71/71.

Author run at `ecd90a635f` (review fixes: vecf8/vecf4 sort compares
cells in place; hash-key preflight sizes the canonical vecf8/vecf4 key;
VECTOR_MATMUL configuration admitted before parsing; volatile/real-time
configuration rejected; JSON options accepted): `pkg/sort`,
`pkg/common/hashmap/...`, `pkg/sql/colexec/aggexec` (with and without
the `gpu` tag), `pkg/sql/colexec/group`, `pkg/sql/plan`,
`pkg/sql/plan/function`, `pkg/sql/compile` and `pkg/container/types`
pass; admission, shared-configuration and sort tests pass `-race
-count=10`; golangci-lint reports no issues; BVT `-m run`: `cases/dtype`
8917 (32 ignored), `cases/function` 22668 + 1 timing flake
(`func_datetime_now.test`, 50/50 on rerun), `cases/vector` 3505 (2
ignored), `cases/array` 1501, `cases/window` 2792 (7 ignored),
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `e38b4def66` (CI fix for
`TestVectorMatmulParseBoundCoversParse`: JSON queries are decoded once,
the row scan finds a null query or coordinate, and the parse bound
carries a 2x margin, at least 2.89x over the measured allocation):
`pkg/sql/colexec/aggexec` passes 5 times in a row, with the `gpu` tag,
under `-race`, and without the simd experiment with coverage.

Author run at `96cb007bc9` (review P2: the admission bound reads neither
options nor query values; options and JSON queries are parsed in one
`sonic/ast` SAX pass, query values rounded once from their text to
float32): `pkg/sql/colexec/aggexec` passes 3 times in a row and with the
`gpu` tag; the options, rounding, scan and admission tests pass `-race
-count=5`; golangci-lint reports no issues; BVT `-m run`:
`vector/vector_matmul.sql` 119/119, `dtype/vecblock.sql` 253/253,
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `8bc61f7f3f` (merge of main `b01e952ad1`, `partition.go`
keeps main's JSON partitioning and the new types' cases; self-review
fixes: the JSON row scan follows at most 8 levels, options and vecblock
queries are checked with `encoding/json.Valid` (nesting limit, trailing
text), duplicate-key error text, vecblock and binary bound terms, limit
checks before options with or without an account, every aggregate
factory attaches the account before the configuration):
`pkg/container/types` (incl. `TestTypeSwitchFamilies`),
`pkg/sql/colexec/aggexec` (with and without the `gpu` tag), `group`,
`window`, `timewin`, `compile`, `hashmap`, `function`, `partition`,
`sort`, `plan` and the parsers pass; the new and affected tests pass
adaptive `-race -count` (N 25 to 100) and the owning packages once under
`-race`; golangci-lint reports no issues; BVT `-m run` 0 failures:
`cases/vector` 3509 (2 ignored), `cases/dtype` 8991 (32 ignored),
`cases/function` 22708 (150 ignored), `cases/window` 2826 (7 ignored),
`cases/array` 1501, `gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `6e2a82ae52` (sonic v1.15.5, whose native decoder rounds
float32 twice (bytedance/sonic#884), so float32 HNSW CDC batches decode
with `encoding/json`; vecblock JSON queries validated before their
elements are collected; self-review fixes): `pkg/sql/colexec/aggexec`
(with and without the `gpu` tag, once under `-race`), `pkg/vectorindex`,
`pkg/vectorindex/hnsw/...`, `pkg/iscp`,
`pkg/sql/colexec/table_function`, `pkg/sql/plan`, `pkg/catalog` and
`pkg/fulltext2/...` pass; new tests pass adaptive `-race -count`;
golangci-lint and molint report no issues; BVT `-m run` 0 failures:
`cases/vector` 3509 (2 ignored), `pessimistic_transaction/vector` 927
(42 ignored), `cases/dtype` 8991 (32 ignored), `cases/fulltext` 2009 (3
ignored), `pessimistic_transaction/fulltext2` 932/932,
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `daef3c9f06` (GROUP_CONCAT selects its accounted DISTINCT
mode from both `SetAllocationAccount` and `SetExtraInformation`, so the
Group factory's account-first order keeps `DISTINCT ... ORDER BY` on the
ordered representation; regression
`TestGroupConcatAccountedDistinctModeIndependentOfOrder` fails without
the fix): `pkg/sql/colexec/aggexec` (also once under `-race`), `group`,
`window` and `timewin` pass; golangci-lint reports no issues; BVT `-m
run` 0 failures: `cases/function` 22708 (150 ignored),
`cases/vector/vector_matmul.sql` 119/119.

Author run at `820f57e2d5` (merge of main `950e548b5a`; full-PR review
fixes: IF/IFF/CASE/COALESCE mixing a low-precision float with another
type resolve as with `float32`, Parquet export writes vecf8/vecf4 as the
exact cell text, the low-precision scalars format as numbers in tuple
and debug printers, `subvector` on vecf8/vecf4 returns `vecf32`):
`pkg/container/types`, `pkg/sql/plan/function`, `pkg/sql/plan`,
`pkg/frontend`, `pkg/sql/colexec/aggexec`, `group`, `tae/common`,
`tae/index` and `logtailreplay` pass; golangci-lint reports no issues;
BVT `-m run` 0 failures: `cases/dtype` 8997 (32 ignored),
`cases/function` 22924 (150 ignored), `cases/array` 1517, `cases/vector`
3531 (2 ignored); at the merge `ee08413830`, `cases/window` 2826 (7
ignored) and `gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `c592c6ac3b` (merge of main `d39d8a4034`: main's DECIMAL
UNSIGNED admission took the next function ids, so `vector_matmul`,
`vecblock_json` and `vecblock_binary` take the ones after it; DECIMAL
UNSIGNED admits bf16/float16/float8/float4 as it admits FLOAT;
`subvector` on vecf8/vecf4 documented as returning `vecf32` equal to
`subvector` over the `vecf32` cast): `pkg/container/types` (incl.
`TestTypeSwitchFamilies`), `pkg/container/vector`,
`pkg/sql/plan/function`, `pkg/sql/plan`, `pkg/sql/colexec/aggexec`,
`pkg/tools/checkpointtool` and the parsers pass; golangci-lint reports
no issues; BVT `-m run` 0 failures: `cases/dtype` 9159 (32 ignored),
`cases/function` 22924 (150 ignored), `cases/vector` 3531 (2 ignored),
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `42eeeb2a77` (merge of main `c8534cc3e2`: main kept the
previous IF/CASE checkers as the native-mode copies and the branch's
low-precision CASE handling had merged into the native copy only, so
both modes now carry it and the conditional tests run in both modes;
main's new TOP pruning excludes vecf8/vecf4 as it excludes the other
float arrays; GPU-tagged static analysis): `TestTypeSwitchFamilies`,
`pkg/container/types`, `pkg/common/hashmap/...`, `pkg/sql/util`,
`pkg/sql/colexec/top`, `aggexec`, `group`, `pkg/sql/plan/function`,
`pkg/sql/plan` and `pkg/vectorindex/...` pass in the GPU build; BVT `-m
run` 0 failures: `cases/dtype` 9438 (32 ignored), `cases/function` 22976
(150 ignored), `cases/vector` 3531 (2 ignored), `cases/array` 1517,
`cases/window` 2838 (7 ignored),
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71,
`cases/vector/vector_matmul.sql` 119/119. **GPU-tagged static analysis**
(CI's `static-check` passes no build tag, so `//go:build gpu` files are
not analyzed there): the configured analyzers with the GPU include paths
of `MO_CL_CUDA=1` and the `gpu` tag, over `./...` — `molint check
-mod=readonly -tags gpu ./...` and `golangci-lint run -c .golangci.yml
--build-tags gpu ./...` (golangci-lint v2.14.0). On the merge they
reported two findings in files this PR adds: `checkunsafe` in
`pkg/cuvs/blockscaled_matmul.go` and `prealloc` in
`pkg/cuvs/blockscaled_matmul_test.go`; `42eeeb2a77` passes the C
pointers through `util.UnsafePointer` and preallocates. On `42eeeb2a77`
the findings equal those of the same commands on main `c8534cc3e2`: 16
molint `checkunsafe` in GPU files this PR does not change
(`pkg/cuvs/{adhoc,brute_force,cagra,device_memory,distance,helper,helper_test,ivf_flat,ivf_pq,kmeans}.go`,
`table_function/{filter_helper,ivfpq_create}_gpu.go`,
`{cagra,ivfpq}/probe_gpu.go`,
`{cagra,ivfpq}/plugin/search/search_gpu.go`) and 1 golangci
`ineffassign` in `pkg/cuvs/search_float_test.go` (unchanged); 0 new.

Author run at `dbfa3ad95e` (GPU-tagged static-analysis findings fixed,
including those main already had: the GPU table functions and the
CAGRA/IVF-PQ search and probe files use `util.UnsafeToBytes`,
`util.UnsafeSliceCast` and `util.UnsafeSizeOf`; `pkg/cuvs` no longer
imports `unsafe`: its cgo calls pass pointers through
`util.UnsafePointer`, and the pinned host-memory API and the VRAM
reservation token hold the C pointer as `*byte`; a `pkg/cuvs` test no
longer assigns a value it overwrites): `molint check -mod=readonly -tags
gpu ./...` (the version `Makefile` pins) and `golangci-lint run -c
.golangci.yml --build-tags gpu ./...` (v2.14.0), with the GPU include
paths of `MO_CL_CUDA=1`, report 0 findings; GPU unit tests pass for
`pkg/cuvs/...`, `pkg/vectorindex/...`, `pkg/sql/colexec/table_function`
and `pkg/sql/colexec/aggexec`; BVT `-m run` of
`test/distributed/gpu_cases` passes 1959/1959 (64 files).

Author run at `f5fad15240` (merge of main `c42cf40214`: main's
`MO_INDEX_SUB_PART` took the next function id, so `vector_matmul`,
`vecblock_json` and `vecblock_binary` move to the ids after it; main's
other commits do not touch GPU-tagged files or `pkg/cuvs`, so the
GPU-tagged static analysis of `dbfa3ad95e` still applies):
`pkg/container/types` (incl. `TestTypeSwitchFamilies`),
`pkg/container/vector`, `pkg/sql/plan/function`, `pkg/sql/plan`,
`pkg/sql/colexec/aggexec` and `group` pass; BVT `-m run` 0 failures:
`cases/vector` 3531 (2 ignored), `cases/dtype` 9438 (32 ignored),
`cases/function` 22976 (150 ignored),
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71.

Author run at `63b315eec7` (main's new `parquet_vector_nonfinite.sql`
expects main's message for a `vecf16`/`vecbf16` element above the type's
range; this PR rejects such an element as out of range, naming the type
and the input value, as the scalar `float16`/`bf16` types do, so the
expected result is updated; both inserts are still rejected):
`cases/load_data` BVT `-m run` 1730 (5 ignored), 0 failures; the other
cases with that message (`dtype/vecblock`,
`vector/vector_nonfinite_conversion`, `array/array_nonfinite`) pass.

Author run at `0b32a9a9f0` (merge `cd4d31b4f3` of main `0df8dded57`:
main's EWM window functions took the next function ids, so
`vector_matmul`, `vecblock_json` and `vecblock_binary` move to the ids
after them, and `aggexec.AggIdOfVectorMatmul` follows; `mysql_sql.go`
regenerated from the merged `mysql_sql.y`; then the vecf8/vecf4
reference doc `0b32a9a9f0`; GPU build): `pkg/container/types` (incl.
`TestTypeSwitchFamilies`), `pkg/sql/plan/function` (incl.
`TestAggregateExecutorIDs`), `pkg/sql/colexec/aggexec`, `pkg/sql/plan`,
`pkg/sql/compile`, `pkg/sql/colexec/window/...`, `pkg/common/hashmap`,
`pkg/iscp` and the parsers pass; `go vet` of `./pkg/... ./cmd/...` (gpu
tag) reports nothing; BVT `-m run` 0 failures: `cases/vector` 3721 (2
ignored), `cases/dtype` 9476 (32 ignored), `cases/window` 3222 (7
ignored), `cases/function` 23144 (150 ignored),
`gpu_cases/vector/vector_matmul_gpu.sql` 71/71,
`gpu_cases/vector/vector_distance_semantics_gpu.sql` 50/50. In the
`cases/function` directory run, `func_datetime_now.test` row 122
(`timestampdiff` of two `now()` values around `sleep(1)` ≥ 1 s) returned
0 in an overnight run where `func_math_floor.test` took 40793 s and
`window.sql` 18395 s; rerun of the three files: 50/50 (6.9 s), 95/95
(3.1 s) and 1106/1106 (55 s).

Author run at `1543470717` (after merging main `be66367687`, GPU build):
the affected Go packages and `TestTypeSwitchFamilies` pass; every `pkg/`
test package compiles; BVT `-m run` 0 failures: `cases/dtype` 8738 (32
ignored), `cases/array` 1501/1501, `cases/vector` 3460 (2 ignored),
`cases/load_data` 1607 (5 ignored), `cases/function` 22196 (150
ignored), and the case file the merge changed. JSONLINE keeps main's
NULL rule: only JSON `null` is NULL, a JSON string `"\N"` is text, and
`$binary` payloads round-trip byte-exact.

Author run at `9cf7b69221` (after merging main `5fb586e142`, GPU build):
the affected Go packages and `TestTypeSwitchFamilies` pass; BVT `-m run`
0 failures: `cases/dtype` 8738 (32 ignored), `cases/array` 1501/1501,
`cases/vector` 3460 (2 ignored), `cases/load_data` 1607 (5 ignored), and
the 3 case files the merge changed.

Author run at `1575c6a696` (after merging main `e19f698de0`, GPU build):
every `pkg/` test package compiles; `TestTypeSwitchFamilies` and the
affected Go packages pass; golangci-lint v2.14.0 reports no issue in the
PR's packages; BVT `-m run` 0 failures: `cases/dtype` 8738 (32 ignored),
`cases/array` 1501/1501, and the 11 case files the merge changed;
`cases/vector` 3449 of 3460 (2 ignored) in the run right after the
restart, where three HNSW/IVF files missed the index plan, and those
three files pass 89/89 when rerun.

Author run at `7af7fc1618` (after `b2e09f6b5e`, and `9d4e8b3130`:
affected Go packages pass, BVT 0 failures for `cases/vector` 3455,
`cases/array` 1501, `cases/dtype` 8738, `gpu_cases/vector` 1360,
`cases/function` 22118, `cases/load_data` 1578, `cases/prepare` 4129,
`cases/dml` 7936; `TestTypeSwitchFamilies` and the affected Go packages
pass; BVT `-m run` 0 failures: `cases/dtype` 8738 (32 ignored),
`cases/vector` 3410 (2 ignored), `gpu_cases/vector` 1360/1360,
`cases/function` 22118 (150 ignored), `cases/array` 1501/1501,
`cases/load_data` 1578 (5 ignored), `cases/ddl` 8610 (168 ignored),
`cases/prepare` 4129 (1 ignored), `cases/table` 2019 (19 ignored),
`cases/dml` 7936 (120 ignored))) on a real device (GPU build,
`MO_CL_CUDA=1`): `TestTypeSwitchFamilies` and the affected Go packages
pass (`container/types`, `sql/plan/...`, `sql/compile`, `aggexec`,
`external`, `externalwrite`, `frontend`, `pb/plan`, `defines`); each new
regression fails with the fix reverted. BVT `-m run`, 0 failures:
`cases/dtype` 8672 (32 ignored), `cases/vector` 3398 (2 ignored),
`gpu_cases/vector` 1360/1360.

GPU-tagged static analysis reports no findings on `dbfa3ad95e` (see the
author run at `dbfa3ad95e`). Device-scale performance remains
**pending**, not counted as a pass; no current end-to-end speedup claim
is made. Rolling deployment does not apply: MatrixOne upgrades by
full-cluster shutdown only. CPU evidence does not establish GPU
acceptance; the documented approximation/subnormal limits remain in
force.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: XuPeng-SH <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: fengttt <[email protected]>
gouhongshen added a commit to gouhongshen/matrixone that referenced this pull request Nov 10, 2026
…schema

information_schema.TABLES rendered TABLE_ROWS/AVG_ROW_LENGTH/DATA_LENGTH/
INDEX_LENGTH as literal zeros and STATISTICS/SHOW INDEX rendered CARDINALITY
as a literal zero even for populated, analyzed tables, because the public
projections never consulted the engine's table statistics (tracked by matrixorigin#30910,
also covering matrixorigin#31752/matrixorigin#31878/matrixorigin#31164).

Publish the maintained statistics through the new resolver builtins
(mo_table_rows/mo_table_data_size/mo_table_index_size/mo_table_col_ndv/
mo_table_col_nullcnt): TABLES and SHOW TABLE STATUS report real row and byte
estimates without double counting, STATISTICS and SHOW INDEX report per-part
cardinality estimates (distinct plus one NULL value group, NULL for an
unavailable estimate or composite/prefix part), subscription-published
views bake the publisher account identity into their persisted bodies, the
session-cached subscription executor's use region is serialized against
interleaving sibling scopes of one statement, stats persistence and
subscription resolution escape quoted identifiers, and the repaired
TABLES/STATISTICS definitions reach existing tenants through the bootstrap
version registry, CREATE ACCOUNT initialization and the CN startup
system-view refresh rail.

Rebased onto current main, merging this PR with the sibling STATISTICS
work that landed in the meantime (matrixorigin#31489/matrixorigin#31662/matrixorigin#31488):

- the byte-stable historical STATISTICS template stays exactly as
  main persists it (CARDINALITY = 0, SUB_PART = NULL); cardinality
  publication and the numeric SUB_PART expression derive from the
  current prefix-Sub_part template only;
- the periodic information_schema maintenance owner deleted upstream
  (matrixorigin#31662) is not reintroduced: existing tenants are repaired through
  the 4.0.7 tenant upgrade entry, CREATE ACCOUNT bootstrap and the
  CN startup InitSystemViews rail, mirroring main's PARTITIONS
  pattern;
- the new builtin ids are renumbered (636-639) behind main's function
  id ledger; every reference stays by name;
- estimator paths honor main's index-relation definition-access
  validation, including publisher-side relation identity checks for
  subscribed tables; the gomock fixtures are extended for those
  guarded calls.

The affected BVT goldens are regenerated under the merged semantics
(numeric SHOW INDEX Sub_part, published CARDINALITY estimates). Suits
whose rows fail identically on current main against main's own goldens
(pre-existing upstream golden drift, verified row-by-row against a
baseline build of this main tip) are left untouched rather than
modernized here.

Related to matrixorigin#30910

This branch was previously deployed

1 inactive deployment
ci — 3b7c384d Deployed Oct 31, 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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants