Skip to content

bug: PR #26284 导致 Big Data Test INSERT...SELECT...ORDER BY spill 磁盘满(no space left on device),级联 inner join 返回 count=0 #26352

Open

Description

@Ariznawlll

问题

PR #26284 (fix: distribute sink scan shuffle hashbuild) 合入后,Big Data Test 的 insert_into_table_limit 数据灌入失败(磁盘满),导致下游 inner join 查询返回 count=0。

影响范围

失败链

Step 1: Limit Insert 失败

insert into big_data_test.insert_into_table_limit
select * from big_data_test.table_basic_for_load_100M
order by col4 limit 5000000
Error 20101: write /tmp/mo-top-spill-2130408090: no space left on device

top-N sort 的 spill 文件写满 /tmp。表 insert_into_table_limit 为空(count=0,期望 5,000,000)。

Step 2: Inner Join 查询结果为空

select count(*) from big_data_test.insert_into_table_limit
inner join big_data_test.table_basic_for_load_100M
on ...col1 = ...col1 limit 300000
  • Expected: count(*) = 1,953,128,852,937
  • Actual: count(*) = 0(因为 insert_into_table_limit 是空表)

时间线

日期 Commit Limit Insert Inner Join
07-24 ~ 07-27 0069d64 / fec60ad ✅ ✅
07-28 36cae2e ❌ no space left ❌ count=0

退化恰好发生在 PR #26284 合入当天。

根因分析

PR #26284 的变更

将 SINK_SCAN 相关的 shuffle hash-build 接收方从集中在 coordinator 1 个 CN,改为分发到所有 query worker CN(3 个):

// Before: 1 个接收节点
stageNode = scopeNodeWithMcpu(stageNode, 1)
return engine.Nodes{stageNode}, true

// After: 所有 query worker 参与
stageNodes := c.queryWorkerStageNodes()

资源影响

  • 之前:shuffle 集中在 1 个 CN,资源压力集中但可控
  • 之后:分发到 3 个 CN 并行执行,所有 CN 同时做更多并发操作 → 内存更紧张 → top-N sort 更早/更多 spill → /tmp 撑满

环境配置缺陷

CN pod 没有配置 ephemeral-storage limit,也没有 emptyDir volume 给 /tmp,spill 文件直接写在节点根文件系统上。

# big-data-tke.yaml CN 配置
tp:
  replicas: 3
  resources:
    requests:
      cpu: 14
      memory: 55Gi
    limits:
      cpu: 14
      memory: 55Gi
  # ⚠️ 没有 ephemeral-storage limit
  # ⚠️ 没有 emptyDir volume for /tmp

建议

  1. 排查 PR fix: distribute sink scan shuffle hashbuild #26284 是否改变了 INSERT...SELECT...ORDER BY 的执行计划(EXPLAIN 对比前后)
  2. 给 CN pod 的 /tmp 配 emptyDir 或 ephemeral-storage limit,隔离 spill 存储
  3. 考虑给 spill 路径加大小限制,避免无限 spill

/cc @jiangxinmeng1

Activity

  1. added
    kind/bug
    on Jul 29, 2026
  2. added theissue type on Jul 29, 2026
  3. added this to the MO-202607 milestone on Jul 29, 2026
  4. added
    severity/s0
    and removed on Aug 2, 2026
  5. Ariznawlll commented on Oct 8, 2026

    @Ariznawlll
    CollaboratorAuthor

    补充 2026-10-08 Big Data Test 1Y(4.2-dev)复现证据:

    • MO commit:c3fa851d810306fac9b8dc3381a49d8193f27a19;本次运行,Limit Insert job。
    • SQL:insert into big_data_test.insert_into_table_limit select * from big_data_test.table_basic_for_load_100M order by col4 limit 5000000。
    • 2026-10-08 02:50:29 UTC,CN nightly-regression-dis-tp-cn-ww2zl 的日志记录:write /tmp/mo-top-spill-2730364518: no space left on device。同一 statement 在 02:50:24 UTC 已出现多个 spill 文件写入失败。目标表最终 count(*) = 0,期望 5,000,000。
    • 同一工作流在 2026-10-06 的 4.2-dev Limit Insert job 成功(8 分 40 秒),说明该语法及用例在 4.2-dev 曾正常执行。本次失败需要继续排查 spill 量、CN 临时盘容量及 spill 文件清理情况。

    现象与此 issue 的 INSERT ... SELECT ... ORDER BY LIMIT 写满 /tmp/mo-top-spill-* 相同。这里仅补充再次复现的证据;本次日志尚不能证明仍由 #26284 的代码变更直接导致。

  6. Ariznawlll commented on Nov 10, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试不通过。2026-11-10 的 4.2-dev Big Data Test 1Y 再次复现 ORDER BY ... LIMIT 写 TOP spill 文件时 no space left on device;后续 Inner Join 的 count(*)=0 是插入失败、目标表为空造成的连带结果,不是独立的 Inner Join 计算错误。

    关键证据

    • 本轮 MatrixOne 版本:4.2-dev@ba2a0caee86dd0f660776560a2a68943abb11df2;完整 run。
    • 08 Limit Insert job 执行 insert into big_data_test.insert_into_table_limit select * from big_data_test.table_basic_for_load_100M order by col4 limit 5000000。2026-11-10 02:20:02 UTC,CN nightly-regression-dis-tp-cn-995z2 记录 write /tmp/mo-top-spill-621706765: no space left on device;客户端于 02:20:04 UTC 收到错误 20101。随后目标表 count(*)=0,预期为 5,000,000。
    • 10 Inner Join job 于 03:02:34 UTC 执行 SQL 成功(约 8.28 ms),但结果为 0,golden 为 1,953,128,852,937;此时上游目标表已经为空。
    • 该 MO 版本的 TOP spill 使用 os.CreateTemp("", "mo-top-spill-*"),即默认临时目录;CN 配置的 2 TB 缓存卷不能直接视为 /tmp 容量。事发节点 10.128.0.198 的根文件系统监控在 02:20:00 UTC 采样仍有约 9.38 GiB 可用,并在失败后回升;这是间隔采样,不能证明写入瞬间的 /tmp 或容器可写层仍有空间。

    待解决点

    • 需核对该 CN 的 /tmp 实际挂载、容器可写层/临时存储配额、spill 峰值与其他占用,才能判定空间耗尽是配置不足、spill 量异常还是清理问题。本轮证据只确认同一失败现象再次出现,不能单独证明仍由 PR fix: distribute sink scan shuffle hashbuild #26284 导致。
    • 测试工作流应让依赖 insert_into_table_limit 的 Inner Join 在 Limit Insert 失败时标记为前置阻塞,避免产生第二个误导性的红灯。
  7. Ariznawlll commented on Nov 12, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试不通过。2026-11-12 的 4.2-dev Big Data Test 1Y 再次复现本 issue 的 TOP spill 写入 /tmp 时 ENOSPC;Limit Insert 未写入数据,后续 Inner Join 的 count(*)=0 是连带结果。

    关键证据

    • 版本:MatrixOne 4.2-dev@5be77ac92b64eba343f1659c21d24c886c6bb98d;workflow main@224aa2fb9909beff2d1222b1a80ced9c5fe09bd9;namespace mo-big-data-43129602219-1。完整 run。
    • 08 Limit Insert job:02:26:10 UTC 开始执行 insert into big_data_test.insert_into_table_limit select * from big_data_test.table_basic_for_load_100M order by col4 limit 5000000;02:27:19 UTC 返回 20101: write /tmp/mo-top-spill-1364833757: no space left on device。随后独立 count(*) 为 0,预期 5,000,000。
    • 同一时间窗口的 TKE Loki 日志显示 CN nightly-regression-dis-tp-cn-d9v6k 先在 02:26:51–02:27:18 UTC 多次记录 TOP spill ENOSPC,入口 CN 随后把该错误返回给客户端。Grafana Prometheus 的 node_filesystem_avail_bytes{instance="10.128.0.52:9100",mountpoint="/"} 显示故障 CN 所在节点根盘(总约 49.15 GiB)可用空间从 02:26:00 UTC 的约 14.91 GiB 降至 02:26:30 UTC 的 0 GiB,02:27:30 UTC 回升至约 28.66 GiB;该 CN 容器可写层在 02:27:00 UTC 约使用 8.96 GiB,CN 重启数为 0。CN 配置虽有 DirectPV 缓存卷,但该卷不等同于 TOP spill 使用的 /tmp 根盘空间。
    • 10 Inner Join job 于 03:35:59 UTC 查询成功但结果为 0,golden 为 1,953,128,852,937;上游目标表已因 Limit Insert 失败而为空。清理 job 成功。

    待解决点

    • 直接故障是 TOP spill 写满 CN 所在节点的根盘。仍需区分 spill 量是否异常、/tmp 容量/挂载配置是否不足,以及其他节点占用;本轮不能单独证明仍由 PR fix: distribute sink scan shuffle hashbuild #26284 的代码变更导致。
    • 为 TOP spill 提供受控且足量的临时存储/容量预检,并让依赖 insert_into_table_limit 的 Inner Join 在前置插入失败时报告阻塞,避免第二个误导性的红灯。
  8. jiangxinmeng1 commented on Nov 12, 2026

    @jiangxinmeng1
    Contributor

    补充定位:#27112 已合入 main。该 PR 将 TOP 的大 LIMIT spill 从 os.CreateTemp("", "mo-top-spill-*") 改为通过 proc.GetSpillFileService() 写入 LOCAL FileService;在本测试集群,LOCAL 位于 DirectPV 缓存卷。因此,本 issue 中 TOP spill 写入 Pod /tmp、耗尽节点根盘的路径已在 main 上修复。

    2026-11-11 的 main 成功运行执行相同的 INSERT ... SELECT ... ORDER BY col4 LIMIT 5000000 时,三台 CN 的根盘几乎不变,DirectPV 盘的观测新增峰值为每节点约 14–29 GiB。相比之下,2026-11-12 失败的 4.2-dev@5be77ac 仍使用 os.CreateTemp 写 /tmp,节点根盘耗尽并报 ENOSPC。

    结论:**本 issue 的根盘写满问题在 main 上已由 #27112 修复;4.2-dev 尚未包含这项 TOP spill 路径修改。**仍需为 spill 所在磁盘保留足够空间。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions