Skip to content

fix(plan): route cluster table inserts through multi-update - #28088

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-27923-27924-cluster-insert
Sep 4, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-27923-27924-cluster-insert

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #27923
issue #27924

What this PR does / why we need it:

Cluster-table INSERT statements fell back to the legacy planner, where generated columns could reach the physical write as NULL and INSERT IGNORE was rejected. This change classifies SystemClusterRel as a regular modern DML target so VALUES, INSERT SELECT, prepared INSERT, INSERT IGNORE, and LOAD DATA use generated/default row construction plus MULTI_UPDATE. Multi-table INSERT remains unsupported for cluster tables and now returns a precise NotSupported error.

Modern routing preserves the previous special-syntax contract: INSERT OVERWRITE on a cluster table and INSERT with PARTITION values return their existing exact NotSupported errors instead of appending rows or ignoring the partition tuple. The regression coverage reaches these checks through the production BuildPlan entry point.

The regression fixture verifies STORED and VIRTUAL generated columns, implicit and explicit account_id placement, serial(id, account_id), dedup planning, special-syntax rejection, and the LOAD path. The cluster-table BVT adds terminal coverage for generated values, composite-key tenant separation, INSERT IGNORE variants, REPLACE/UPDATE/ODKU recomputation, LOAD DATA INLINE, tenant permission errors, exact special-syntax errors, explicit generated-column rejection, and CHECK-failure atomicity.

Validation on 9ba9a52:

  • focused CGo planner tests: PASS; the original regression tests fail on parent ffc8d9f, and the special-syntax BuildPlan test fails on prior PR head d71c8e8
  • complete ./pkg/sql/plan CGo test package: PASS
  • rebased TestCommitWithLockTablesChanged after upstream test(txn): isolate lockservice operation deadlines #28069: PASS
  • make build: PASS
  • cluster_table BVT: PASS 258/258 twice on one readiness-complete instance; cleanup postconditions PASS
  • git diff --check: PASS
  • semantic preflight review: PASS, diff hash b4ad69a703b391306ba0e920379920597e9019f83fdf9028fa69ba70c0696b8b

CI is running on the rebased exact head; QA is pending. QA still needs the exact PR build sys/tenant matrix and the 2-CN + Proxy write/reconnect/read smoke.

@mergify mergify Bot added the kind/bug Something isn't working label Sep 3, 2026
@matrix-meow matrix-meow added the size/M Denotes a PR that changes [100,499] lines label Sep 3, 2026
@VioletQwQ-0
VioletQwQ-0 force-pushed the codex/issue-27923-27924-cluster-insert branch from dc1b650 to 9ba9a52 Compare September 4, 2026 05:06
@VioletQwQ-0
VioletQwQ-0 marked this pull request as ready for review September 4, 2026 06:02
@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 →

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

Deep review completed at exact HEAD 1a42d49. No blocking findings.\n\nThe routing change matches the relation invariant: a cluster table is a normal persisted DML target with an added tenant key, not an internal vector/text index table. Admitting SystemClusterRel at the existing modern-path gate reuses the generated/default row-image construction and dedup + MULTI_UPDATE machinery, while DMLContext still rejects non-sys writes before planning. The composite key remains serial(id, account_id), explicit/implicit account_id placement is preserved, and INSERT IGNORE retains duplicate suppression instead of falling back to the misleading unsupported-index error.\n\nI checked the broadened surface across VALUES, INSERT SELECT, prepared INSERT, LOAD, REPLACE/ODKU compatibility, generated columns, CHECK atomicity, tenant rejection, and multi-table INSERT. The explicit multi-table rejection prevents the new classification from accidentally admitting an unsupported shape, and the pre-route OVERWRITE/PARTITION-value checks preserve the legacy exact errors. No new resource ownership, waits, or unbounded state are introduced. Exact-head CI is green.\n\nIndependent validation passed: git diff --check and the focused cluster INSERT, special-syntax, LOAD, and unsupported multi-insert planner tests.

@mergify

mergify Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@XuPeng-SH XuPeng-SH 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 exact HEAD 1a42d49. No blocking findings.

The routing change is constrained to SystemClusterRel: non-sys writes are still rejected during DML target resolution, while sys writes now reuse the established generated/default row-image, dedup, and MULTI_UPDATE pipeline. I traced implicit and explicit account_id, composite-key serialization, VALUES/SELECT/prepared/LOAD inputs, INSERT IGNORE mixed duplicate/new rows, REPLACE/ODKU/update recomputation, generated-column rejection, and CHECK atomicity. The resulting plan keeps tenant identity in both the write image and conflict key.

Counterexamples at the syntax boundary remain closed: cluster INSERT OVERWRITE and PARTITION-value syntax retain their exact rejection before row construction, and multi-table INSERT rejects cluster targets explicitly. No new shared state, resource lifecycle, or unbounded work is introduced. Exact-head required CI is green, and the focused planner plus cluster-table BVT evidence exercises the changed public path.

@mergify mergify Bot added the queued label Sep 4, 2026
@mergify

mergify Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-04 11:55 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-04 12:02 UTC · at e5fb673006ca430ef8eec24b269df7ec679cf3f2

This pull request spent 6 minutes 48 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #28088 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Failing checks:

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 243b77a into matrixorigin:main Sep 4, 2026
20 of 21 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 4, 2026
@VioletQwQ-0
VioletQwQ-0 deleted the codex/issue-27923-27924-cluster-insert branch September 6, 2026 09:43
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#28088)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#27923
issue matrixorigin#27924

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

Cluster-table INSERT statements fell back to the legacy planner, where
generated columns could reach the physical write as NULL and INSERT
IGNORE was rejected. This change classifies SystemClusterRel as a
regular modern DML target so VALUES, INSERT SELECT, prepared INSERT,
INSERT IGNORE, and LOAD DATA use generated/default row construction plus
MULTI_UPDATE. Multi-table INSERT remains unsupported for cluster tables
and now returns a precise NotSupported error.

Modern routing preserves the previous special-syntax contract: INSERT
OVERWRITE on a cluster table and INSERT with PARTITION values return
their existing exact NotSupported errors instead of appending rows or
ignoring the partition tuple. The regression coverage reaches these
checks through the production BuildPlan entry point.

The regression fixture verifies STORED and VIRTUAL generated columns,
implicit and explicit account_id placement, serial(id, account_id),
dedup planning, special-syntax rejection, and the LOAD path. The
cluster-table BVT adds terminal coverage for generated values,
composite-key tenant separation, INSERT IGNORE variants,
REPLACE/UPDATE/ODKU recomputation, LOAD DATA INLINE, tenant permission
errors, exact special-syntax errors, explicit generated-column
rejection, and CHECK-failure atomicity.

Validation on 9ba9a52:

- focused CGo planner tests: PASS; the original regression tests fail on
parent ffc8d9f, and the special-syntax BuildPlan test fails on prior
PR head d71c8e8
- complete ./pkg/sql/plan CGo test package: PASS
- rebased `TestCommitWithLockTablesChanged` after upstream matrixorigin#28069: PASS
- make build: PASS
- cluster_table BVT: PASS 258/258 twice on one readiness-complete
instance; cleanup postconditions PASS
- git diff --check: PASS
- semantic preflight review: PASS, diff hash
b4ad69a703b391306ba0e920379920597e9019f83fdf9028fa69ba70c0696b8b

CI is running on the rebased exact head; QA is pending. QA still needs
the exact PR build sys/tenant matrix and the 2-CN + Proxy
write/reconnect/read smoke.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#28088)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#27923
issue matrixorigin#27924

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

Cluster-table INSERT statements fell back to the legacy planner, where
generated columns could reach the physical write as NULL and INSERT
IGNORE was rejected. This change classifies SystemClusterRel as a
regular modern DML target so VALUES, INSERT SELECT, prepared INSERT,
INSERT IGNORE, and LOAD DATA use generated/default row construction plus
MULTI_UPDATE. Multi-table INSERT remains unsupported for cluster tables
and now returns a precise NotSupported error.

Modern routing preserves the previous special-syntax contract: INSERT
OVERWRITE on a cluster table and INSERT with PARTITION values return
their existing exact NotSupported errors instead of appending rows or
ignoring the partition tuple. The regression coverage reaches these
checks through the production BuildPlan entry point.

The regression fixture verifies STORED and VIRTUAL generated columns,
implicit and explicit account_id placement, serial(id, account_id),
dedup planning, special-syntax rejection, and the LOAD path. The
cluster-table BVT adds terminal coverage for generated values,
composite-key tenant separation, INSERT IGNORE variants,
REPLACE/UPDATE/ODKU recomputation, LOAD DATA INLINE, tenant permission
errors, exact special-syntax errors, explicit generated-column
rejection, and CHECK-failure atomicity.

Validation on 9ba9a52:

- focused CGo planner tests: PASS; the original regression tests fail on
parent ffc8d9f, and the special-syntax BuildPlan test fails on prior
PR head d71c8e8
- complete ./pkg/sql/plan CGo test package: PASS
- rebased `TestCommitWithLockTablesChanged` after upstream matrixorigin#28069: PASS
- make build: PASS
- cluster_table BVT: PASS 258/258 twice on one readiness-complete
instance; cleanup postconditions PASS
- git diff --check: PASS
- semantic preflight review: PASS, diff hash
b4ad69a703b391306ba0e920379920597e9019f83fdf9028fa69ba70c0696b8b

CI is running on the rebased exact head; QA is pending. QA still needs
the exact PR build sys/tenant matrix and the 2-CN + Proxy
write/reconnect/read smoke.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…igin#28088)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#27923
issue matrixorigin#27924

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

Cluster-table INSERT statements fell back to the legacy planner, where
generated columns could reach the physical write as NULL and INSERT
IGNORE was rejected. This change classifies SystemClusterRel as a
regular modern DML target so VALUES, INSERT SELECT, prepared INSERT,
INSERT IGNORE, and LOAD DATA use generated/default row construction plus
MULTI_UPDATE. Multi-table INSERT remains unsupported for cluster tables
and now returns a precise NotSupported error.

Modern routing preserves the previous special-syntax contract: INSERT
OVERWRITE on a cluster table and INSERT with PARTITION values return
their existing exact NotSupported errors instead of appending rows or
ignoring the partition tuple. The regression coverage reaches these
checks through the production BuildPlan entry point.

The regression fixture verifies STORED and VIRTUAL generated columns,
implicit and explicit account_id placement, serial(id, account_id),
dedup planning, special-syntax rejection, and the LOAD path. The
cluster-table BVT adds terminal coverage for generated values,
composite-key tenant separation, INSERT IGNORE variants,
REPLACE/UPDATE/ODKU recomputation, LOAD DATA INLINE, tenant permission
errors, exact special-syntax errors, explicit generated-column
rejection, and CHECK-failure atomicity.

Validation on 9ba9a52:

- focused CGo planner tests: PASS; the original regression tests fail on
parent ffc8d9f, and the special-syntax BuildPlan test fails on prior
PR head d71c8e8
- complete ./pkg/sql/plan CGo test package: PASS
- rebased `TestCommitWithLockTablesChanged` after upstream matrixorigin#28069: PASS
- make build: PASS
- cluster_table BVT: PASS 258/258 twice on one readiness-complete
instance; cleanup postconditions PASS
- git diff --check: PASS
- semantic preflight review: PASS, diff hash
b4ad69a703b391306ba0e920379920597e9019f83fdf9028fa69ba70c0696b8b

CI is running on the rebased exact head; QA is pending. QA still needs
the exact PR build sys/tenant matrix and the 2-CN + Proxy
write/reconnect/read smoke.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

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 size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants