Repository navigation
Description
Is there an existing issue for the same tech request?
- I have checked the existing issues.
Does this tech request not affect user experience?
- This tech request doesn't affect user experience.
What would you like to be added ?
At this moment, MO will parse a query and based on some logic to determine if the query is a AP query or TP query. TP query is executed on the current CN (handling connection), and AP will be executed on ALL available CN (and with all threads on each CN).
This is unreasonably restrictive. In theory, a query can be executed on ANY or ANY subset of CNs, and especially, the subset of CNs does not need to include current CN (client is connected)Why is this needed ?
To utilize hardware info much more efficiently.
Additional information
There is a routing decision that should be made after query parsing. It could be automatic, intelligent, for example, look at ALL CNs, pick up CNs with load less than 50%. Use this subset of CN.
Or a more manual style. For example, we can give each CN a tag, so a cluster may have say, a few TP CNs, a few ETL CNs, and some AP CNs. Let's assume clients are all connected to TP CNs. After parsing, we can execute all TP queries in current CN. For LOAD, etc, run the work on the ETL CNs, and for large AP queries, send to those AP CNs. These different CNs (TP, LOAD, AP) does not need to have same hardware resource.
We can optimize allocation, for example, more memory for TP CNs and less memory, but more disk bandwidth for ETL CNs, etc.
One interesting case, is that we can have many customers, each have its own TP CN, let's assume each customer has just one TP CN. A shared pool of AP CNs for all customers to run AP queries. Note that this case the AP query is executed on a subset of CNs that does not include current CN.
Also on TPC-C like workload, we can have a bunch of CNs, based on the warehouse id after query parsing, we either execute the query on current CN, or, route the the CN that "owns" the partition. If we do this, TPC-C does not have any distributed transactions. This is actually quite common because some experienced DBA will shard data exactly to avoid transactions across shards.
Finally, I do not know if our AP queries runs correctly on several CNs if each of them are configured with different number of CPUs. And I don't think we can run a query only use a subset of the CPUs on a CN -- that is, if we can run a pipeline with parallelism 4 even if the machine has 8 cores. But these may not as important if we fully embraces K8S -- we can always partition a bigger machine to a standard "unit" size.
But worth find out where we fail right now and understand the problems at least.
Activity
refactor(sql): extract query scheduling rules (#25461)
fix(sql): harden remote scheduling failure paths (#25492)
refactor: split scheduling facade and harden fallback paths (refactor #…
refactor(schedule): decouple current CN placement policy (#25517)
refactor(schedule): decouple current CN placement policy (matrixorigi…
refactor(schedule): introduce staged query placement (#25537)
refactor(schedule): harden runtime worker scheduling (#25564)
refactor(schedule): expose bounded statement scheduling trace (#25581)
scheduler: add pool-aware deterministic worker subsets (#25990)
XuPeng-SH commentedon Aug 12, 2026
Product-first reset for #25451 — 2026-08-13
1. What product are we actually building?
The customer-facing promise should be:
A customer should be able to answer, before running a workload:
“Pick CNs below 50% CPU”, “TP versus AP”, “use CN-3”, and “match these raw labels” are not product contracts. They are heuristics, current implementation details, or examples from the original request.
2. Industry calibration
Mature systems expose a stable compute or admission boundary and keep machine selection internal:
MatrixOne should follow these responsibility boundaries, not copy any one product's syntax.
3. MatrixOne's minimal stable model
MatrixOne already has an operational concept of named cnGroups / CN resource groups, created by the Operator and selected by Proxy for a connection (current MatrixOne documentation). Query scheduling must build on that one compute identity rather than introduce a second unrelated “pool”.
Use three concepts, introduced only when their behavior exists:
Compute group (existing CN group; final public name to be decided once)
Binding / assignment
Admission policy (later)
The internal flow is:
Authorization and hard execution constraints always win; load information may rank an eligible set but may never widen it.
4. Required product behavior
Default and compatibility
Unavailable versus overloaded
These are different states:
Configuration changes
Session and transaction ownership
The scheduler cannot override correctness:
Classification
Separate business intent from execution capability:
Observability
For every scheduled attempt, operators need bounded-cardinality visibility of:
EXPLAIN/preview must not mutate state or claim admission that has not happened.
5. What current code has established
Current main (6a29b7d at this review) has useful internal foundations from #25461, #25492, #25496, #25517, #25537, #25564, #25581, and #25990:
This is infrastructure, not the completed product. TP and AP-one-CN still remain on ingress; advertised CPUTotal is static DOP input, not live free capacity; there is no admission, reservation, bounded shared-pool fairness, or transaction-owner routing.
6. Product review of #26109
#26109 contains valuable internal work that should be preserved or extracted:
However, its public product surface should not merge as-is:
The correct action is to re-scope #26109, not continue patching the JSON model:
7. Outcome-gated roadmap
This replaces numbered implementation phases.
Milestone A — product contract and canonical compute identity
Deliver an RFC and executable acceptance matrix before more public API code:
Exit gate: product, control-plane, Proxy, transaction, and SQL owners agree on the contract; two real deployments are expressible without contradictory names or fallbacks.
Milestone B — static compute-group execution MVP
Implement only:
Do not add live CPU scoring, generic selector DSL, shared-pool fairness, or autoscaling.
Exit gate: real multi-CN E2E covers autocommit/read-only analytics, supported LOAD, ingress-only input, first DML, explicit transaction read-your-writes, prepared execution, retry, cancellation, draining, address/membership change, mixed version, and cross-account denial. The disabled path has no catalog/RPC and no material allocation/latency regression.
Milestone C — stable workload assignment
After explicit group selection works, add only selectors justified by real customers: for example authenticated account/role, client source or explicit workload tag, and statement kind. Define deterministic precedence and a mandatory default. Keep optimizer TP/AP classification internal.
Automatic plan-based assignment is a separate opt-in experiment and ships only if it is predictable enough to beat explicit/static assignment in the acceptance workloads.
Exit gate: the same request resolves identically across CNs and retries for a fixed policy generation; every decision is explainable; no selector can widen ACLs.
Milestone D — admission and shared-group safety
When contention measurements show the need, start with the smallest explainable mechanism: group-level concurrent-query permits plus a bounded cancellable queue. Define a single owner and idempotent release across success, error, timeout, cancellation, retry, CN loss, and restart.
Cross-account shared groups are enabled only here, after per-account limits/fairness and audit exist.
Exit gate: overload tests prove bounded memory/waiters, no permit leak/double release, defined queue fairness, preserved TP tail latency, and useful queue/reject metrics.
Milestone E — heterogeneous capacity and dynamic placement
Only after admission owns capacity:
A single instantaneous CPU threshold and per-query cluster polling are explicitly rejected.
Exit gate: controlled mixed-workload tests show a material repeatable gain in throughput or P95/P99 queue/query latency without correctness, isolation, stampede, oscillation, or steady fast-path regression. Otherwise retain the simpler static policy.
Independent track — transaction/data-locality routing
TPCC warehouse/partition affinity requires partition ownership, routing-key availability (including prepared parameters), transaction-begin pinning, owner generation, cross-owner transaction behavior, and failover. It should consume the compute-group eligibility contract but must not be hidden inside query worker placement.
Immediate decision
refactor: define canonical compute-group execution and harden ingress…
refactor(sql): extract query scheduling rules (matrixorigin#25461)
fix(sql): harden remote scheduling failure paths (matrixorigin#25492)
12 remaining items
refactor(schedule): harden runtime worker scheduling (matrixorigin#25564
refactor(schedule): expose bounded statement scheduling trace (matrix…
scheduler: add pool-aware deterministic worker subsets (matrixorigin#…
refactor: define canonical compute-group execution and harden ingress…
refactor(sql): extract query scheduling rules (matrixorigin#25461)
fix(sql): harden remote scheduling failure paths (matrixorigin#25492)
refactor: split scheduling facade and harden fallback paths (refactor m…
refactor(schedule): decouple current CN placement policy (matrixorigi…
refactor(schedule): introduce staged query placement (matrixorigin#25537
refactor(schedule): harden runtime worker scheduling (matrixorigin#25564
refactor(schedule): expose bounded statement scheduling trace (matrix…
scheduler: add pool-aware deterministic worker subsets (matrixorigin#…
refactor: define canonical compute-group execution and harden ingress…