Repository navigation
Closed
Labels
kind/bugSomething isn't workingseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.
Milestone
Description
Summary
On soak fa6c57c (4.2-dev), global Top-N from system.statement_info is dominated by dump/monitor traffic, not business TPCC/sysbench/TPCH:
dumpslow-query monitor —SELECT … FROM system.statement_info WHERE duration > 1s AND request_at > NOW()-1mruns ~every 3 minutes, routinely 2–4 minutes, spikes to 10–20 minutes, while scanning ~27–32M rows / ~15–18 GB (near full table).dumpgetSumStorage — per-account aggregate onmo_cloud.storage(600M rows / 1000 accounts): avg ~133s, max ~573s, ~700–850 queries/hour.
Business workloads in the same window did not show progressive slowdown; these two fingerprints explain why “global slowest” looks pathological.
Environment
| Field | Value |
|---|---|
| Cluster / namespace | mo-stb-4-2-dev-fa6c57c-202608041202 |
| Deploy / image | fa6c57c → rolled to matrixone:commit-c8dae1d45 (~2026-08-06 10:19–10:25 CST) |
| Endpoint | 10.222.6.255:6001 |
| Artifact | /data1/stability-test/30876385810_fa6c57c |
| Analysis window | 2026-08-05 18:30 CST → 2026-08-06 ~03:00 CST |
| User | dump |
Table sizes (live COUNT)
| Table | Rows | Span | Notes |
|---|---|---|---|
system.statement_info |
31,643,154 | 2026-08-04 04:07 → 08-06 02:59 | ~2-day retention; ~14–16M rows/day |
mo_cloud.storage |
600,000,000 | 2025-10-13 → 2026-05-19 | 1000 accounts × 600k rows; stale vs wall clock (no Aug data) |
mo_cloud.storage monthly (all 1000 accounts):
| Month | Rows |
|---|---|
| 2025-10 | 52.0M |
| 2025-11 | 82.5M |
| 2025-12 | 85.2M |
| 2026-01 | 85.2M |
| 2026-02 | 77.0M |
| 2026-03 | 85.2M |
| 2026-04 | 82.5M |
| 2026-05 | 50.5M (truncated at 05-19) |
Dump’s hot window May 1–May 19: 49,472,000 rows total (49,472 / account).
Issue A — statement_info self-scan
SQL
SELECT statement, duration / 1000000000 as duration_sec
FROM system.statement_info
WHERE duration > 1000000000
AND request_at > DATE_SUB(NOW(), INTERVAL 1 MINUTE)
ORDER BY duration DESC
LIMIT 10Latency & frequency (user=dump)
| Metric | Value |
|---|---|
Samples (duration > 5s) |
141 |
| min / avg / max | 23s / 195s / 1204s |
| Duration buckets | <60s:19 · 60–180s:76 · 180–300s:43 · 300–600s:9 · ≥600s:4 |
| Hourly rate | mostly 17–20 / hour |
| Inter-arrival | avg ~209s (serial: each run takes minutes) |
| Spike hour | 2026-08-06 01:00 — 4 runs, avg 831s, max 1204s (01:16 / 01:34) |
rows_read / bytes_scan |
avg ~27.4M / ~15 GB, max ~31.7M / ~18 GB |
Filter claims “last 1 minute + duration>1s”, but each invocation still reads near the entire retained statement_info.
Expected vs actual
| Expected | Actual |
|---|---|
| Last-1-minute filter → small range / index scan | Near full-table read (tens of millions of rows, tens of GB) |
| Monitor finishes in seconds | Steady minutes; spikes >10–20 min |
| Monitor does not become the global Top-N | Dominates global slowest list |
Likely mechanism
- Predicate on
duration+request_at/DATE_SUB(NOW(), …)may not prune objects (cast / non-sargable / missing suitable index). - Table is wide (
statementTEXT +exec_planTEXT) → high bytes_scan even when row filter should be selective. - Harness runs this on a growing ~30M-row table every few minutes → self-amplifying load.
Proposed fixes
MO / schema
- Ensure range-friendly access for
request_at(consider(request_at, duration)or covering path for this monitor shape). - Avoid plans that cast
request_at/NOW()in a way that blocks time pruning.
Harness / ops
- Stop scanning full
statement_infofor Top-N; use metrics / sampled / pre-aggregated path, or boundrequest_atwith literal timestamps (noNOW()in SQL). - Raise interval / add timeout; never run overlapping monitors.
- Exclude
user='dump'from “global business slowest” dashboards.
Issue B — mo_cloud.storage getSumStorage
SQL
SELECT sum(`value`*`interval`) as storage,
sum(`snapshot_value`*`interval`) as snapshot_storage
FROM `mo_cloud`.`storage`
WHERE collecttime > ?
AND collecttime <= ?
AND account = ?
-- example binds: 2026-05-01 08:55:23 ; 2026-05-19 08:55:23 ; <uuid>Latency & frequency
| Metric | Value |
|---|---|
Samples (duration > 5s) |
~3100 |
| min / avg / max | 27s / 133s / 573s |
| Duration buckets | <30s:3123 · 30–60s:117 · 60–120s:1315 · 120–300s:1647 · ≥300s:9 |
| Rate | ~700–850 / hour (batch of accounts ~every 60s; inter-arrival avg ~4.8s) |
rows_read / bytes_scan |
avg ~24.4M / ~2 GB, max ~49.5M / ~10.5 GB |
Likely mechanism
- 600M-row table; PK shape
(collecttime, account)is suboptimal for hot pathaccount = ?+ time range. - Planner often chooses large Table Scan / over-reads (tens of millions of rows) for an ~50k-row/account May window.
- High QPS under soak amplifies CN IO/CPU pressure.
Proposed fixes
CREATE INDEX idx_storage_account_collecttime
ON mo_cloud.storage(account, collecttime);- Verify EXPLAIN uses account + time range (not multi-million-row Table Scan).
- Target: <5s / account after index.
Out of scope
- Progressive slowdown of TPCC / sysbench / TPCH business SQL (not the Top-N drivers in this window).
- Leak-txn / wait-active (separate).
Reproduce / verify
EP=10.222.6.255
mysql -h$EP -P6001 -udump -p111 -e "
SELECT COUNT(*) FROM system.statement_info;
SELECT COUNT(*), MIN(collecttime), MAX(collecttime), COUNT(DISTINCT account)
FROM mo_cloud.storage;"
mysql -h$EP -P6001 -udump -p111 -e "
SELECT ROUND(duration/1e9,1) sec, rows_read, ROUND(bytes_scan/1024/1024,1) mb,
LEFT(statement,120) stmt
FROM system.statement_info
WHERE user='dump' AND request_at >= DATE_SUB(NOW(), INTERVAL 6 HOUR)
ORDER BY duration DESC LIMIT 20;"
EXPLAIN /* statement_info monitor + storage getSumStorage */;
SHOW INDEX FROM mo_cloud.storage;Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't workingseverity/s0Active / top priority for current sprint. Owner has committed to working on it now.
Activity
aptend commentedon Aug 6, 2026
We investigated the two slow-query patterns separately.
1. system.statement_info
This is an MO optimizer issue.
request_at is DATETIME(6), while DATE_SUB(NOW(), ...) is resolved as TIMESTAMP. The binder was casting request_at to TIMESTAMP, hiding the storage column behind a cast and preventing effective object/block pruning.
PR #26755 changes the safe column-vs-statement-constant case to cast the value side to DATETIME instead. Lossy precision conversions, volatile expressions, and column-dependent expressions retain the existing behavior.
A local EXPLAIN ANALYZE comparison on the final PR commit showed:
2. mo_cloud.storage
This has a different cause and is expected under the current detail-table design.
The storage recorder periodically writes one record for every account. Organizing the table by (collecttime, account) makes these writes monotonic and append-friendly, reducing object-range overlap and LSM merge/write amplification. Changing the ordering to account-first for this one query, or adding a large secondary index, would trade the read improvement for additional write, storage, and compaction cost.
getSumStorage recalculates daily/month-to-date totals from the detail table. Its scan cost is therefore expected to grow roughly in proportion to the time-window length. If that growth is unacceptable, the appropriate optimization is in mocloud-services: retain the time-first detail table, add coarser hourly/daily rollups, reuse completed-window totals, and scan only the latest incomplete raw window.
The 600 million rows in this soak were explicitly preloaded from storage_6b.csv by the stability workflow; they were not generated during this soak. They are still useful for exposing the scaling behavior, but the linear scan growth itself is not evidence of an MO storage-engine defect.
In summary, PR #26755 addresses the statement_info problem. The storage path should be followed up as a rollup/caching optimization in mocloud-services rather than by changing MO pruning semantics.
aptend commentedon Aug 10, 2026
Follow-up on the
system.statement_infopart: after further cross-database and DST review, we are replacing the value-side cast approach from #26755. Casting aTIMESTAMPboundary toDATETIMEis not semantics-preserving across time-zone folds, so that is not the final design.PR #26918 instead adds direct
DATETIME/TIMESTAMPcomparison support while keeping the existing public function result types and instant semantics. The rawrequest_atcolumn remains visible to storage pruning. Zonemap conversion is applied only when theDATETIMErange is order-preserving in the session time zone; a range intersecting a DST fold or gap is conservatively retained for residual evaluation. FractionalTIMESTAMPprecision is also preserved.On a local two-object reproduction, the natural predicate
produced a direct block filter and reduced the table scan from two blocks to one. The
mo_cloud.storageconclusion in the previous comment is unchanged.fix: preserve zonemap pruning for DATETIME/TIMESTAMP comparisons (#26918
aptend commentedon Aug 10, 2026
Final update: PR #26918 has been merged as
dcef98c269and supersedes #26755. Thesystem.statement_infopruning problem is now fixed inmainusing directDATETIME/TIMESTAMPcomparison support without changing public temporal-function result types. Themo_cloud.storageanalysis and rollup/caching recommendation above remain unchanged.[4.2] fix: preserve zonemap pruning for DATETIME/TIMESTAMP comparisons (
Ariznawlll commentedon Aug 13, 2026
验证结果:已不复现
在 4.2-dev 稳定性测试集群(
mo-stb-4-2-dev-b83878b-202608102354,commitb83878b)上检查了最近 48 小时的慢查询:Exec.Run 慢查询统计
对比原始问题
statement_info自扫描getSumStorage(mo_cloud.storage)slow event
仅有 S3FS.Read 文件系统 I/O 事件,无 SQL 层面的慢查询。
结论
statement_info自扫描和getSumStorage的分钟级慢查询在当前 4.2-dev 稳定性测试中已不复现,最慢查询仅 11.3 秒。Ariznawlll commentedon Aug 14, 2026
补充核查与结论更正
进一步核对了 #26741 的修复和当前运行镜像,结论如下。
1.
system.statement_info修复已进入当前 4.2-dev 环境dcef98c269)43cad0efd9ed)matrixone:commit-321849021321849021479e8bb8cf82286b3ec83bca86bf7f7当前 SHA 已包含 #27097,因此
request_at > DATE_SUB(NOW(), ...)的 DATETIME/TIMESTAMP zonemap pruning 修复已经部署。2.
mo_cloud.storage getSumStorage仍然慢更正上一条“最慢 Exec.Run 11.3s / getSumStorage 未复现”的结论。补充按
account sys:dump过滤后,同一批 20 条查询的服务端Exec.Run为:q2hlb:55.9–66.3sxtwd7:32.3–34.8s每条查询仍枚举约 6042 个 blocks;profile 热点在
Group -> TableScan -> BlockDataRead -> S3FS/DiskCache -> LZ4 decode。因此 storage 性能问题仍存在。3. Issue scope / follow-up
#27097 只修复
system.statement_infopruning,不涉及getSumStorage。根据研发上面的结论,剩余 storage 延迟来自当前(collecttime, account)明细表设计,应在 mocloud-services 中通过小时/天级汇总、复用已完成时间窗口的结果、仅扫描最新未完成 raw window 来继续跟踪和优化。建议先关联对应的 mocloud-services 跟踪单,避免剩余性能问题丢失;关联后,本 issue 的 MO engine 修复范围可以视为完成。
Ariznawlll commentedon Aug 26, 2026
Scope resolution and migration
This issue originally contained two independent performance problems observed by the 4.2-dev stability test.
1.
system.statement_infoself-scan — fixedcommit-d239386contains the backport.2.
mo_cloud.storage/getSumStorage— moved to MatrixFlowgetSumStorageis a MOC service operation rather than a MatrixOne kernel function. The remaining problem is now tracked in:The new tracking issue includes the complete call path, previous MatrixFlow/mocloud-services history, and current 4.2-dev evidence. Current observations still show minute-scale latency: the latest 20 samples average approximately 154s, with a maximum of approximately 215s.
Closing this MatrixOne issue because the MatrixOne pruning defect is fixed and the remaining service-side work has been migrated. This closure does not mean that
getSumStoragehas been fixed.fix: preserve zonemap pruning for DATETIME/TIMESTAMP comparisons (mat…
fix: preserve zonemap pruning for DATETIME/TIMESTAMP comparisons (mat…
fix: preserve zonemap pruning for DATETIME/TIMESTAMP comparisons (mat…