Skip to content

fix(sql): preserve ROLLUP provenance across remote batch transport - #29115

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/issue-29096-rollup
Sep 19, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/issue-29096-rollup

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #29096

What this PR does / why we need it:

Preserve vector grouping provenance across both remote batch senders and the
shared receiver. Previously the wire retained NULLs and aggregate/hash metadata,
but dropped grouping bits: a ROLLUP sentinel became an ordinary SQL NULL,
splitting hash domains or violating NOT NULL partial-group metadata. In-memory
Dup tests hid the lossy edge.

  • Add an optional framed pipeline-only grouping extension, retaining Attrs,
    ExtraBuf and parameter/string provenance. Non-grouping wire bytes, persistent
    vectors and spill format are unchanged.
  • Require MORPC87 on participating CNs. Probe selected workers and actual
    sending destinations/sources, including a stripped top-level Dispatch and
    forwarding-only scopes. Preserve the query requirement through redispatch;
    fail closed for old/unknown peers without blocking local-only ROLLUP.
  • Retain existing merge-group nullability validation and empty-set identities.
  • Extend existing group tests through the real codec, and reuse the shared
    dual-CN fixture with physical peer-address proof and exact result assertions.
  • Re-enable the existing [Bug]: mo report 'invalid input: missing FROM-clause entry for table 'c'' while mysql can execute successfully. #20000 JOIN/ENUM ROLLUP BVT instead of adding a duplicate
    fixture; replace its old unknown-result placeholder with independently derived
    totals (139.95 = 89.96 +49.99) and all11 grouping-level rows.

Design and review

GPT-6 medium produced the design and performed whole-change R3 wire/compatibility
review. Fixed its two intermediate compatibility findings (stripped Dispatch
destinations and local-only placement), and the final P2 assertion-failure
cleanup finding. Re-review: code APPROVE, no outstanding code blockers.

Validation evidence

Base: 3ac87c30625fc082391e5384a4c94e50a2916cf6; Linux/amd64, Go1.26.4,
native CPU build via make cgo. Go tests use .agents/skills/mo-dev/scripts/mo-cgo-test.

  • Root-cause ablation: overlay only the encoder with the former provenance-only
    codec; TestPipelineGroupingRoundTrip fails at the lost grouping marker,
    completed exit1. Current codec normal/race tests pass.
  • Normal full packages: batch, dispatch, group, compile and DML all pass.
    Final group40.216s, compile7.854s, DML408.560s. DML includes forced remote
    SQL for true NULL vs ROLLUP, NOT NULL/window, empty input, CTE, COALESCE and JOIN.
  • Focused race: batch/dispatch/compile pass; latest compile1.229s. Includes
    malformed/truncated payloads, decoder reuse, peer rollback/unknown versions,
    forwarding scope redispatch and stripped Dispatch checks. MPool returns to0.
  • Incremental SCA: changed closure is batch, defines, dispatch, group, compile,
    DML. gofmt, go vet -mod=readonly, golangci-lint2.6.2 with
    --new-from-rev 3ac87c30625fc082391e5384a4c94e50a2916cf6: exit0, 0 issues.
    This is not a claim that full repository CI/SCA ran.
  • Candidate make build-with-prebuilt-native: exit0. Binary SHA256:
    23f491cf9ddf5ad54742fff0034aa6d323e7ccfd34e2848cae4e4768ba231b91.
  • All five original MOTR cases from ebed6c8db2f19c48a5581a136fd2915f084d0d36
    pass on the candidate service:20000,25287,25499,26022,26269 (the last file's
    additional SQL-semantics cases also pass). Executed original SQL and compared
    tab-separated results exactly with upstream .result after removing only
    echoed query text; no expected values changed. Catalog teardown:0 databases.
  • Candidate BVT, normal comparison on a fresh standalone two-CN data directory:
    function/mysql_compat_null_rollup_grouping.sql:7/7 twice;
    unskipped window/rollup.sql:228/228 twice,0 failed/ignored/abnormal.
    Each run confirms0 remaining test databases. Existing .sql/.result format
    retained; the newly enabled golden was independently calculated and approved
    by GPT-6 medium, not generated from candidate output.

Remaining risks / rollout

  • Remote grouping queries from a new coordinator require every participant at
    MORPC87; old/unknown peers get an explicit unsupported error. Old coordinators
    are not retroactively protected by this change.
  • Drain in-flight queries before replacing/downgrading binaries. Capability
    probes do not fence a connection replacement after the probe.
  • Grouping batches carry O(vector count + bitmap bytes) additional metadata;
    grouping forwarding scopes also carry the existing query-plan field.
  • No production TKE rerun or full-repository race/SCA is claimed. Local dual-CN
    topology evidence and candidate BVT/SQL results are distinguished below.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

COMMENT — PASS at 61814b64b483e14c36666fcf95cfe5c902e9b062; self-authored PR, so comment only. No actionable P0–P2 findings after tracing grouping provenance through batch encoding, both senders, remote execution, decoding, merge consumers, compatibility gates, cleanup and reuse.

The codec preserves payload/ExtraBuf and validates grouping framing; forwarding carries the requirement through scopes; remote clients reconstruct each batch before decoding and use existing terminal cleanup on errors. The dual-CN TestRollupRemoteGroupingProvenance passed in exact-head CI.

Residual evidence gaps: no verified real mixed-binary execution or grouping-specific fragmentation, cancellation/retry, and prepared-reexecution matrix. Old-coordinator execution and post-probe binary replacement remain rollout limitations.

@XuPeng-SH
XuPeng-SH merged commit 3fe7840 into matrixorigin:main Sep 19, 2026
18 of 20 checks passed
@XuPeng-SH
XuPeng-SH deleted the fix/issue-29096-rollup branch September 19, 2026 20:41

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ROLLUP merge-group emits synthetic empty NULL groups and corrupts GROUPING()/aggregates

2 participants