Repository navigation
Description
Description
在 TKE big-data 10Y 多 CN 环境中,向带复合主键和二级索引的目标表执行 10 亿行 INSERT SELECT 时,SQL 运行满 7200 秒仍未完成。三个 TP-CN 在执行期间均触碰 55 GiB cgroup 内存上限,并持续出现大量 memory failcnt;MO 同时反复记录 iscp transaction finish timeout 和事务重试。客户端到达配置的 SQL timeout 后关闭连接,最终目标表仍为空。
Environment
- Branch:
main - MatrixOne commit:
9a5dd0c6e32a62e4393c2e7fbcab57b53f0c58c0 - MatrixOne image:
matrixone:commit-9a5dd0c - mo-nightly-regression commit:
6d19e8f31bf1597aa3121277afef86a16049d4b9 - Deployment: TKE big-data 10Y,3 CN + 1 DN
- CN/DN memory limit:
55 GiB - Namespace:
mo-big-data-commit-9a5dd0c-suite-10y - SQL timeout:
7200s - Test date:
2026-09-11(UTC+8)
Steps to reproduce
准备 big_data_test.table_with_pk_for_load_1B 后执行:
python run.py \
-H <MO_ADDRESS> \
--sql-timeout 7200 \
-c ./cases/big_data_test/03_INSERT_SELECT/08_table_with_com_pk_index_for_insert_1B.sql核心 SQL:
insert into big_data_test.table_with_com_pk_index_for_insert_1B(
id,col1,col2,col3,col4,col5,col6,col7,col8,col9,
col10,col11,col12,col13,col14,col15,col16,col17,col18,col19,
col20,col21,col22,col23,col24,col25
)
select *
from big_data_test.table_with_pk_for_load_1B
where col4 != -7508478199581380391;Actual behavior
Client and proxy timeline
2026-09-11 04:23:42.516UTC+8:proxy 建立测试客户端到 CNnightly-regression-dis-tp-cn-695nf的连接。2026-09-11 04:23:42.527:开始执行上述 SQL。2026-09-11 06:23:42.527:恰好 7200 秒后,客户端记录(2013, 'Lost connection to MySQL server during query'),并在同一毫秒记录Execution timeout after 7200s。2026-09-11 06:23:42.813:proxy 记录同一条长连接关闭;CN 随后出现query interrupted、context canceled和 connector cleanup timeout。- 失败后目标表
count(*) = 0,期望值为999999998。
测试脚本同时把 PyMySQL read_timeout/write_timeout 和外层 func_timeout 设置为 7200 秒,因此 Lost connection 与 Execution timeout 的打印顺序是两个相同 deadline 竞争的结果。它解释最终的客户端错误,但不能解释 MO 为何两小时仍未完成 SQL。
Memory pressure
查询窗口:2026-09-10 20:23:42–22:23:42 UTC。
| Pod | cgroup limit | max usage | max working set | max page cache | failcnt increase |
|---|---|---|---|---|---|
TP-CN 695nf |
55 GiB | 55 GiB | 32.11 GiB | 35.75 GiB | +62,437,095 |
TP-CN lwdxg |
55 GiB | 55 GiB | 30.80 GiB | 36.54 GiB | +72,425,072 |
TP-CN p8jcl |
55 GiB | 55 GiB | 29.29 GiB | 37.29 GiB | +70,668,220 |
DN dn-0 |
55 GiB | 40.26 GiB | 39.85 GiB | 1.90 GiB | 0 |
三个 TP-CN 均精确触碰 cgroup hard limit,且 failcnt 在单次 SQL 中增加 6200–7200 万,说明执行期间持续发生内存顶限和回收压力。但未发生容器级 OOM kill:
container_oom_events_total = 0- 所有 MO 容器 restart count 为 0
- 无
OOMKilled、exit 137、Evicted 或 terminated reason - Kubernetes node
MemoryPressure=true为 0
MO logs and profiles
- 协调 CN 持续出现
iscp transaction finish timeout,多个 CN 出现txn need retry in rc mode。 - 超时取消时出现
query interrupted、object writercontext canceled和 connector cleanup timeout。 - Pyroscope 显示三个 CN 的 MO mpool 约稳定在 12.56 GiB,Go heap 峰值约 1.98–2.29 GiB;大量 cgroup usage 来自 page cache,而不是 Go heap 持续增长。
- CN
p8jclgoroutine 约为 1431–1752,另外两个 CN 约为 302–992;未观察到持续单调增长。 06:14–06:15UTC+8 附近多个 CN 出现 mutex contention 峰值,随后 SQL 仍未完成。
Expected behavior
该 INSERT SELECT 应在历史正常预算内完成并插入 999999998 行,不应持续两小时后由客户端超时取消。MO 在内存接近 cgroup limit 时也应保持可控的执行进度,或返回明确的资源错误,而不是长期停留在事务 finish/retry 状态。
Stability and controls
- Reproducer: 当前 CI 记录
1/1;原 namespace 已清理,尚未完成独立3/3重复确认。 - Control: perf: big-data insert into select performance optimization. #26133 中同一
04 Com PK Index Insert在相同 3 CN + 1 DN、55 GiB 配置下,历史 main 版本约 75–94 分钟完成;本次超过 120 分钟且未完成。 - Failure atomicity/data check: 超时后目标表行数为 0,没有观察到部分提交。
- Exclusions: 无 OOM kill、容器重启、节点 MemoryPressure 或 proxy 崩溃证据;最终连接关闭发生在客户端配置的 7200 秒 deadline。
Evidence
- Run: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34496566063
- Failed job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34496566063/job/102977790778
- MatrixOne commit: 9a5dd0c
- Test timeout wiring:
- https://github.com/matrixorigin/mo-nightly-regression/blob/6d19e8f31bf1597aa3121277afef86a16049d4b9/tools/mo-regression-test/run.py#L68-L70
- https://github.com/matrixorigin/mo-nightly-regression/blob/6d19e8f31bf1597aa3121277afef86a16049d4b9/tools/mo-regression-test/scripts/execute_sql.py#L58-L59
- Grafana selectors:
- Prometheus:
namespace="mo-big-data-commit-9a5dd0c-suite-10y" - Loki:
{namespace="mo-big-data-commit-9a5dd0c-suite-10y"} - Pyroscope:
{service_name="mo-big-data-commit-9a5dd0c-suite-10y/main",pod="<pod>"}
- Prometheus:
Code analysis
已确认直接失败链路是客户端配置的 7200 秒 timeout 关闭连接;这不是 MO 进程被 OOMKilled 或 proxy/COS 主动断连。MO 侧在超时前长期存在 CN cgroup 内存顶限、回收压力、ISCP transaction finish timeout、事务重试和 mutex contention。
当前证据支持“MO 分布式 INSERT SELECT/事务完成路径在严重内存压力下卡顿”这一判断,但尚不足以把具体代码级根因唯一归到某个函数。需要开发侧结合超时前的 mutex/goroutine profile 和 ISCP transaction 状态继续定位。
Regression coverage
修复后复用该 big-data 10Y case,至少验证:
- SQL 在历史预算内完成并得到
999999998行; - TP-CN 不再长时间触碰 cgroup limit、failcnt 不再持续快速增长;
- 无持续
iscp transaction finish timeout和 RC retry; - 超时取消能够及时终止服务端执行并释放事务、connector 和 goroutine 资源。
Related
- perf: big-data insert into select performance optimization. #26133:同一组 10Y
INSERT SELECT的历史性能优化问题;其中该 SQL 仍可在约 75–94 分钟完成,本问题记录超过 120 分钟未完成的回归。 - [Bug]: 10Y Math SUM(EXP()) runs beyond 7200s and leaves CN execution resources occupied #28560:不同 SQL(
SUM(EXP()))的长时间执行和取消清理问题,症状相关但执行路径不同。
Activity
XuPeng-SH commentedon Sep 11, 2026
Triage decision: promote to severity/s0 and assign to aptend.
Evidence: the TKE 3-CN/55-GiB run kept the core 1B composite-PK INSERT SELECT unfinished for 7200s; all three CNs reached the cgroup limit, failcnt increased by roughly 62–72 million, and repeated ISCP transaction-finish timeouts/RC retries were observed. This is a confirmed high-impact execution stall/performance failure. The exact code-level root cause still needs profile-guided isolation; do not broaden the fix before that evidence is obtained.
aptend commentedon Sep 11, 2026
补充 profile、代码差异和轻量复现后的调查结论:本问题已经定位到具体代码级性能回归,不只是笼统的内存压力。
排除 planner/stats
正常版本
596b2f2和异常版本9a5dd0c的相关 planner 行为一致。两次运行都执行两个 distributed HashBuild,均为 42 个实例且每个实例发生一次 spill;spill 数据量也基本一致:第一阶段约 152 GiB,第二阶段约 177 GiB。因此 stats/lookup fallback 是既有优化空间,但不是这次版本间回退的引入点。实际回退位置
正常运行与异常运行的阶段耗时:
异常版本 profile 中,新增 CPU 热点明确落在:
vector.PrepareMarshalBinaryvector.MarshalBinaryPlan.MarshalTohashbuild.marshalSpillRecordAccounteddispatch.shuffleToAllFunc引入点是 #28145 /
f0c31cd4b8的 borrowed-varlen canonical marshal。UnionInt32实际会把每个非 const 长值复制到独立的新 area 区间,但此前仍保守地把areaDisjoint清为 false。新 marshal 逻辑因此把普通 shuffle 和 HashBuild spill 的分桶 batch 当成 alias vector,逐行扫描 descriptor、创建 canonical map/offset,并逐 descriptor 写出。8192 行 varchar 的同路径微基准结果:
对应修复:#28724
修复只在目标 vector 原本是 owned 且 disjoint、来源为非 const selection 时保留 disjoint proof。const 重复值以及 borrowed/alias/window 仍走 canonical marshal,因此不放宽 Arrow borrowed backing 的安全边界。
已通过 vector、batch、shuffle、HashBuild 全包测试,并增加 selection marshal 正确性测试和基准。10Y 端到端运行可作为合入后的最终性能确认,不再是定位或证明修复所必需的前置条件。
perf(vector): preserve bulk marshal for selected varlen (#28724)
Ariznawlll commentedon Sep 14, 2026
测试版本
main6875e4203519de1ed98b842c1cbc8c57f11dc32617db47f8faa0dce438d7eb2b4c35a560509f02cc。tools/mo-regression-test/cases/big_data_test/03_INSERT_SELECT/08_table_with_com_pk_index_for_insert_1B.sql。原问题验证
故障版本
9a5dd0c6e32a62e4393c2e7fbcab57b53f0c58c0执行相同 10 亿行复合主键、二级索引INSERT SELECT时,运行满 7200 秒仍未完成;客户端到达同一 deadline 后断开,目标表最终为 0 行。原始证据:run 34496566063 / job 102977790778。修复后验证
在修复后的 commit
6875e4203519de1ed98b842c1cbc8c57f11dc326上,以完全相同的 SQL 和--sql-timeout 7200执行该 10Y 用例:2026-09-13 03:35:15.384(UTC+8)。INSERT SELECT完成:2026-09-13 05:11:50.905(UTC+8)。5,795,520.92 ms,即约 96 分 36 秒,在 7200 秒限制内完成。select count(*) from big_data_test.table_with_com_pk_index_for_insert_1B成功执行并完成 golden 校验;预期与实际均为999999998行。success;日志中Lost connection to MySQL server during query、Execution timeout after 7200s、rpc stream closed、context canceled、query interrupted、Traceback均为 0 次。验证 Job:run 34702559343 / Insert 10Y · 04 Com PK Index Insert。整个 run 的失败来自其他 Query 10Y 用例,不是本 Issue 对应的
04 Com PK Index Insert用例。修复说明
研发已定位回退点为 #28145 引入的 selected varlen canonical marshal 路径:本应可批量 marshal 的 owned/disjoint varchar batch 被保守标记为 alias,导致 HashBuild spill 和 shuffle 对 descriptor 逐行处理。#28724 仅在满足 owned、disjoint、非 const selection 的条件下保留 disjoint proof,其余 borrowed/alias/window 等路径仍使用 canonical marshal,未放宽 Arrow borrowed backing 的安全边界。
回归测试
#28724 已完成 vector、batch、shuffle、HashBuild 相关测试,并新增 selection marshal 正确性测试和基准;PR 的 CI Required、TKE BVT、TPCH/SSB、Sysbench、TPCC、UT 等检查均通过。
测试证据
测试结论
测试通过。
perf(vector): preserve bulk marshal for selected varlen (matrixorigin…
perf(vector): preserve bulk marshal for selected varlen (matrixorigin…
perf(vector): preserve bulk marshal for selected varlen (matrixorigin…