Repository navigation
Closed
Bug
Copy link
Description
Description
在 TKE big-data 10Y 多 CN 环境中,SUM(EXP(...)) 扫描 1B 行数据时不能在回归预算内完成。第一次查询运行满 7200 秒后超时,脚本继续发起后续同类查询;第二次也运行满 7200 秒,第三次仍在执行时整个 workflow 被取消。
Environment
- Branch:
main - MatrixOne commit:
4b43f8c99bb22e6a35c389c93bf64c2dc043feaf - Deployment: TKE big-data 10Y,3 CN(每个 14 CPU / 55 GiB)
- Namespace:
mo-big-data-commit-4b43f8c-suite-10y - SQL timeout:
7200s - Actions run: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34297650895
- Job: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34297650895/job/102397107562
Steps to reproduce
准备 big_data_test.table_basic_for_load_1B 后执行 10Y Math case:
python run.py --sql-timeout 7200 -c ./cases/big_data_test/04_QUERIES/04_math_1B.sql
其中至少包含:
select sum(exp(col3)) from big_data_test.table_basic_for_load_1B;
select sum(exp(col9)) from big_data_test.table_basic_for_load_1B;
select sum(exp(col10)) from big_data_test.table_basic_for_load_1B;Actual behavior
sum(exp(col3))从 2026-09-09 10:06:57 UTC 执行到 12:06:57 UTC,客户端记录(2013, 'Lost connection to MySQL server during query')和Execution timeout after 7200s。- 脚本随后继续执行
sum(exp(col9)),同样运行 7200 秒后超时;随后启动sum(exp(col10)),在 14:14:36 UTC workflow 被取消。 - 超时期间 CN
nightly-regression-dis-tp-cn-ngksx持续出现iscp transaction finish timeout;同时出现 connector cleanup timeout(context canceled)。 - 该 CN 的 Prometheus
go_goroutines在 12:00–14:15 UTC 为 1464–1563(平均约 1523),其他两个 CN 分别约 318–420(平均约 339、352)。 container_oom_events_total为 0,CN 无重启;因此当前证据不支持 OOM 或容器崩溃是直接原因。
Expected behavior
SUM(EXP(...)) 应在 big-data 10Y 的正常预算内完成,或及时返回明确的溢出错误;客户端超时后应取消服务端查询并释放执行资源,不应让后续同类查询叠加运行。
Stability and controls
- Reproducer: 当前 CI 记录 1/1;该 run 的 namespace 已被清理,尚未完成独立 3/3 重复确认。
- Control: 在较早的 main commit
845fff8ee9cac962c5002a1007e0b0180efd591b(run https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34003161298)中,同三条EXP查询在约 10 分钟内返回1690 data out of range,没有出现每条 7200 秒的长时间占用;该旧行为另有兼容性 issue [Compatibility]: POWER, EXP overflow and COT domain errors abort queries instead of returning NULL #28137 跟踪。 - 相关但不同:[Bug]: 10Y median(col3) exceeds 7200s in accounted aggregate path #27413 只涉及
median()的 accounted aggregate 路径;[Compatibility]: POWER, EXP overflow and COT domain errors abort queries instead of returning NULL #28137 只涉及EXP溢出结果语义。
Evidence
- GitHub Actions job 日志:上述 job 链接,包含两次 7200s timeout、
Lost connection和第三条查询启动记录。 - Loki(TKE,窗口 12:05:57–12:20:57 UTC 与 14:05:57–14:20:57 UTC):
iscp transaction finish timeout、connector cleanup timeout。 - Prometheus(selector
namespace="mo-big-data-commit-4b43f8c-suite-10y"):go_goroutines、container_memory_working_set_bytes、container_oom_events_total。 - Pyroscope(service
mo-big-data-commit-4b43f8c-suite-10y/main,CNngksx,同两段窗口):goroutine、CPU、Go heap、malloc、mutex、block profile 均有数据。
Code analysis
当前只能确认服务端查询在 1B 行 EXP 聚合路径长时间占用执行资源,并伴随 ISCP transaction finish timeout;尚未从 profile 得到足以确认具体函数的调用栈,因此根因暂标为待 MatrixOne 开发进一步定位,不将其归因于 COS 或 OOM。
Regression coverage
修复后增加一个聚焦的 10Y SUM(EXP()) 回归:记录每条 SQL 耗时,验证超时取消能终止服务端执行,并检查 CN goroutine、事务和连接在取消后回落;同时保留小数据集的溢出语义测试。
Related
- Source CI failure: https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34297650895
- Related (different behavior): [Bug]: 10Y median(col3) exceeds 7200s in accounted aggregate path #27413, [Compatibility]: POWER, EXP overflow and COT domain errors abort queries instead of returning NULL #28137
Activity
Ariznawlll commentedon Sep 10, 2026
详细指标与 profile 分析
本次分析使用同一 job 的两个 15 分钟窗口:
sum(exp(col3))超时点)sum(exp(col9))超时点及第三条查询启动后){namespace="mo-big-data-commit-4b43f8c-suite-10y"}{service_name="mo-big-data-commit-4b43f8c-suite-10y/main",pod="..."}CPU为process_cpuprofile 的纳秒值,Go heap为memory:inuse_space,malloc为malloc:inuse_space。Pyroscope(CNSet)
4659wngksxq4dsl4659wngksxq4dsl结论:
ngksx的 goroutine 数在两个窗口都稳定在约 1.5k,约为另外两个 CN 的 4–5 倍;CPU profile、mutex、block 也同时偏高,但 Go heap 和 malloc 没有出现独立的突增。因此更符合“查询/事务执行未及时结束并产生等待或清理堆积”,而不是 OOM。Prometheus(14:06:00 UTC 瞬时值)
go_goroutinescontainer_memory_working_set_bytes{container="main"}container_oom_events_total{container="main"}4659wngksxq4dsl三台 CN 在 14:06 的工作集均低于 55 GiB 限制,OOM 计数均为 0。
Loki 事件统计
iscp transaction finish timeout共 91 条,全部来自nightly-regression-dis-tp-cn-ngksx。ngksx。err=context canceled。与 job 日志的对应关系
sum(exp(col3))和sum(exp(col9))各自完整占用 7200 秒;客户端虽然记录超时并继续下一个 SQL,但服务端对应 CN 仍出现 transaction finish/connector cleanup 超时。第三条sum(exp(col10))启动后,workflow 于 14:14:36 UTC 被取消。这些数据确认了超时期间存在 CN 侧执行资源堆积和清理异常,但当前 profile 结果仍不足以确认具体代码函数;具体根因需要开发侧结合对应 goroutine dump/CPU 火焰图继续定位。
perf(function): avoid EXP overflow error allocations (#28592)
daviszhen commentedon Sep 10, 2026
修复已通过 PR #28592 合入
main,merge commit:e3959405658a2607b590aef63e648c5c068fa5e4。根因
EXP溢出当前采用逐行返回NULL的语义,但原执行路径仍会为每个溢出值调用momath.Exp,创建并格式化一个完整的moerr.NewOutOfRangeNoCtxf,随后opUnaryFixedToFixedWithNullOnError只设置 NULL bitmap 并丢弃该错误。在 10 亿行大量溢出的
SUM(EXP(...))场景中,这会产生海量无效错误对象、字符串格式化、堆栈采集和 GC 工作,与问题中观察到的高 CPU、mutex/block 和执行资源堆积相符。本地未修复版本的 allocation profile 显示:
momath.Exp -> NewOutOfRangeNoCtxf累计占 benchmark 分配空间约 95.5%;fmt.Sprintf约占 22.3%。修改
EXP直接执行math.Exp,通过 infinity 检查识别溢出并设置行级 NULL;性能对比
8192 个全部溢出的输入值,每次 benchmark:
函数热点约提升 120-155 倍,分配次数不再随溢出行数线性增长。修复后 CPU profile 热点回归为实际的
math.Exp计算和 NULL bitmap 写入。验证
以下本地验证均通过:
go test ./pkg/sql/plan/function -count=1-count=5go vet ./pkg/sql/plan/functiongit diff --check还需要 nightly 使用合入后的 commit 重跑原 10Y 三条
SUM(EXP(...))查询,确认端到端耗时以及 CN goroutine/connector cleanup 指标恢复。Ariznawlll commentedon Sep 11, 2026
已在
maincommit9a5dd0c6e32a62e4393c2e7fbcab57b53f0c58c0验证,已包含修复 PR #28592(merge commite3959405658a2607b590aef63e648c5c068fa5e4)。原来运行满 7200 秒仍超时的三条 SQL,本次执行耗时分别为:
sum(exp(col3)):2.079 秒sum(exp(col9)):2.008 秒sum(exp(col10)):1.903 秒未再出现执行超时或
Lost connection。当前 Math job 标红是已有 golden 与新返回结果不一致,不是该性能问题再次出现。验证任务:https://github.com/matrixorigin/mo-nightly-regression/actions/runs/34496566063/job/103101071409
测试通过。
perf(function): avoid EXP overflow error allocations (matrixorigin#28592
perf(function): avoid EXP overflow error allocations (matrixorigin#28592
perf(function): avoid EXP overflow error allocations (matrixorigin#28592