Skip to content

scheduler: add pool-aware deterministic worker subsets - #25990

Merged
XuPeng-SH merged 12 commits into
matrixorigin:mainfrom
XuPeng-SH:refactor_schedule_phase8_0721
Jul 22, 2026
Merged

XuPeng-SH merged 12 commits into
matrixorigin:mainfrom
XuPeng-SH:refactor_schedule_phase8_0721

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:

Related to #25451

What this PR does / why we need it:

This is the Phase 8 scheduler capability PR. It makes pool intent and deterministic worker-subset selection first-class across frontend, compile, engine resolution, scan/stage placement, tracing, and EXPLAIN.

Key points:

  • Adds statement/session scheduling intent, strict versus legacy-compatible pool fallback, empty-worker policy, explicit worker locality, and resolved pool identity.
  • Adds deterministic HRW max-workers(N) selection with stable membership and final execution ordering; the ingress CN may remain coordinator without being a query worker.
  • Resolves tenant/label pools with truthful fallback metadata, candidate-owned CPUTotal, participant compatibility filtering, and strict no-cross-pool behavior.
  • Removes the historical QueryClient != nil -> CurrentCNRequired proxy and prevents remote scope failures from silently moving execution back to the coordinator.
  • Carries raw per-statement scheduling intent through multi-statement, cached-plan, prepared, retry, and EXPLAIN paths, with fail-closed parsing and prepared SQL-mode preservation.
  • Closes review-found correctness and lifecycle gaps: invalid intent is rejected before control-plane discovery, route correlation handles missing/duplicate IDs, memoryengine no-match semantics are truthful, deterministic selection has a bounded fallback key, and prepared caches are bypassed without destroying reusable default topology.

Validation:

  • Relevant package tests and race tests for pkg/sql/schedule, pkg/vm/engine/disttae, pkg/vm/engine/memoryengine, pkg/sql/compile, and pkg/frontend.
  • go build, go vet, git diff --check, and scheduling benchmarks.
  • make dev-build and make dev-up with a fresh five-service cluster.
  • Real 5,000,000-row AP execution with strict max-workers(1): CN1 remained ingress/coordinator, CN2 was the only query/scan/stage worker, and sum(a) returned 12500002500000.

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

@LeftHandCold LeftHandCold left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-reviewed the updated head. The previous strict-isolation blocker is closed: disttae and memoryengine now fail closed with an empty label selector under strict policy, while legacy-compatible requests retain all-compatible behavior. The direct Session -> frontend -> compile path reaches no-match and unsatisfied placement, so no cross-pool remote worker can be launched. I also rechecked resolver coverage/wrappers, placement termination, default compatibility, retry/reuse, and lifecycle/unhappy paths; no additional actionable blocker found. Focused regressions under -race, full disttae/memoryengine/frontend/schedule/compile tests, and affected-package build/vet pass locally.

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

Re-reviewed the updated head at 2d759fa. The previous strict-pool isolation blocker is closed: both disttae and memoryengine fail closed when strict policy has no CN label selector, while legacy-compatible behavior remains unchanged. The no-match result propagates through placement to an unsatisfied compile result before scope materialization or remote launch. Focused regressions passed under race for three iterations; full frontend, disttae, and memoryengine tests and vet also passed locally. No remaining blocking findings.

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/enhancement kind/feature kind/refactor Code refactor size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants