Skip to content

fix(vector): preserve CN labels for internal SQL - #28204

Merged
mergify[bot] merged 10 commits into
matrixorigin:4.2-devfrom
ck89119:issue-27966-4.2-dev
Sep 9, 2026
Merged

mergify[bot] merged 10 commits into
matrixorigin:4.2-devfrom
ck89119:issue-27966-4.2-dev

Conversation

@ck89119

@ck89119 ck89119 commented Sep 5, 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:

issue #27966

What this PR does / why we need it:

Preserves the initiating statement's CN label selector across frontend background sessions, process snapshots, remote pipeline serialization, vector-index SQL execution, and nested internal SQL compilation.

This prevents internal IVF SQL generated by a TP-labeled query from losing its compute-pool constraint and being scheduled onto an AP CN.

The label maps are cloned at ownership boundaries so compile cleanup or caller mutation cannot alter the parent statement's routing constraint. Standalone background SqlContext and auto-commit paths remain unconstrained.

Tests cover frontend inheritance, executor option ownership, remote/two-hop process propagation, nested compile snapshots, and vector-index batch/streaming/transaction paths.

@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

Choose a reason for hiding this comment

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

Re-reviewed exact head fd40672 against its actual declared base 4.2-dev at 588295f (also merge-base). The 20-file change map remains the frontend statement snapshot -> background session -> process/remote codec -> vector/internal executor -> nested compile routing chain. Routing source, generated protobuf and tests are unchanged from the previous reviewed head apart from unrelated base-side compile lifecycle/database changes, so prior matching evidence is reusable. Read the production propagation and test changes again and checked that the generated payload/schema are unchanged from the prior review.

[P2: mandatory validation gap] Add the actual frontend-to-remote IVF routing regression

pkg/frontend/back_exec_test.go:163-251 still constructs a backSession, extracts its labels/intent and directly supplies both to PreviewQueryScheduling at line 222. The fake provider also supplies the already-filtered CN set. This bypasses doComQueryInBack, real generated IVF SQL, internal-executor option construction, remote encoding/decoding and execution candidate resolution. The complete changed-file list still adds no embedded/BVT integration scenario. Consequently this test does not fail when one of the production propagation edges responsible for #27966 is disconnected.

The prior requested proof remains required under the repository public multi-CN/pool-isolation test contract: start with a TP-labeled frontend statement, execute generated IVF work through the production background/internal/remote chain, assert the actual selected CNs stay in TP, and cover strict no-match failure plus query_max_workers inheritance. Do not inject the final SchedulingIntent directly into a scheduler preview. Reuse a minimal existing multi-CN fixture and publish exact-head selection and terminal evidence.

The known implementation defect is already fixed: complete scheduling intent is captured, child SQL does not widen it, and label maps are cloned at ownership boundaries. No new concrete implementation blocker is claimed. Q1/Q3 close through independent bounded metadata snapshots and normal session/process/compile ownership; this patch adds no new asynchronous worker or wait chain. Wire additions are additive and previously checked codec evidence remains applicable. Current generic green CI does not establish the missing composition scenario. No local native/cluster run performed.

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

Exact-head re-review: 00de364, current base 027194e. APPROVE: no confirmed blocker remains.

The current 21-file map covers frontend statement/background snapshots, internal executor options, remote process codec, vector SQL consumers, nested compile and integration evidence. Compared with our last reviewed fd40672 head, 17 in-scope files (including schema/generated protobuf) are unchanged and their evidence is reused; all new hunks in the remaining four files were read. I also re-traced the production routing chain. Immutable label clones and the complete statement-owned intent preserve pool strictness, worker cap and child-SQL ownership across the reviewed boundaries. The new parent-back-session walk closes the missing upstream sysvar lookup without replacing the already captured immutable statement policy.

The previous requested composition proof is now present: TestIssue27966FrontendIVFInternalSQLPreservesQueryPool starts a real four-CN fixture, sends the production proxy label preface to a frontend connection, verifies IVF selection, executes the public SQL and observes generated entries SQL at production placement. It checks exact query results, TP-only two-worker placement with a remote worker, then invalidates TP labels after outer admission and checks the generated internal query fails closed with no selected workers. This does not inject a prefiltered candidate set into PreviewQueryScheduling. Current CI run 34216932428 reports that named test PASS, 23.26 seconds (11:25:33–11:25:56 UTC); I did not run a local cluster.

The service-scoped observer copies value-only worker records, uses synchronized registration, and cleanup removes only its own entry; test collection is mutex-protected and fixture/query lifetimes are bounded. With no observer installed the production addition is a map lookup, not new I/O or asynchronous work. Existing codec/ownership evidence remains applicable, with no new wire delta in this revision. No demonstrated routing, concurrency, resource or unhappy-path defect was found. Head and applicable green CI were revalidated immediately before submission.

@aunjgr aunjgr 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 00de364d7a9c191c417af23177c0b6ec1ebab9d4 against 4.2-dev at 027194e3ac2a41226059116ccb61d1432410edde. No confirmed merge-blocking finding remains.

I traced statement/background-session labels and scheduling intent through process serialization, executor options, nested compile, and vector-index batch/streaming/transaction SQL. Maps are independently cloned at ownership boundaries; the intent contains value-only fields. Parent strict-pool/worker-cap policy survives generated child SQL, while standalone background contexts stay separate.

The non-generated change map, schema/generated field mapping, NULL/default ownership controls, and real four-CN integration fixture were reviewed. Observer registration/removal is service-scoped and synchronized; callbacks receive independently owned worker records. No additional lifecycle or unbounded-state blocker was found.

Reused exact-head successful CI and the existing real frontend/proxy-label -> IVF internal SQL -> production placement evidence, including fail-closed pool loss. No local cluster was rerun. Head, open/non-draft state and passing applicable CI were rechecked before submission.

@mergify

mergify Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-09 09:18 UTC · Rule: release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-09-09 09:18 UTC · at a33d3a1bbbfa507ef1efc7c3748ab70e07d3bcd9 · squash

This pull request spent 16 seconds in the queue, including 1 second running CI.

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

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/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants