Skip to content

[Bug]: MODUMP max_file_size panics with 'cannot create context from nil parent' when splitting large results #30552

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

b24d1b3 (2026-10-16)

Other Environment Information

  • Hardware: macOS arm64 (Apple Silicon)
  • Topology: single-node standalone (./mo-service -launch etc/launch/launch.toml, LOG+TN+CN single process)
  • OS: macOS

Actual Behavior

MODUMP QUERY_RESULT ... INTO ... max_file_size <small> panics with internal error: panic cannot create context from nil parent whenever the exported result is large enough to trigger file splitting.

ERROR 20101 (HY000) at line 1: internal error: panic cannot create context from nil parent:
context.withCancel
	golang.org/x/sync/errgroup.WithContext
	github.com/matrixorigin/matrixone/pkg/frontend.init.func52
	...

The panic is recovered (the server stays alive) but the export fails every time, so max_file_size splitting is completely unusable on large results.

Root cause (source level): pkg/frontend/export.go:205 does ep.AsyncGroup, _ = errgroup.WithContext(ctx). For the MODUMP path the ctx passed into openNewFile originates from execCtx.reqCtx, which is nil for this statement type, so errgroup.WithContext(nil) panics.

Steps to Reproduce

create database md;
create table md.big (id int auto_increment primary key, val int);
insert into md.big (val) values (1);
-- double until ~2048 rows (11 doubling inserts)

set save_query_result=on;
/* save_result */ select * from md.big order by id;
select last_query_id();   -- capture the id

-- this panics:
modump query_result '<id>' into '/tmp/out.csv' max_file_size 1;

-- this works (no split triggered):
modump query_result '<id>' into '/tmp/out.csv' max_file_size 100000;

Reproduced 3/3 times on separate standalone instances; behaviour is deterministic.

Expected Behavior

max_file_size should split the output into multiple files without panicking. A nil context must never reach errgroup.WithContext.

Additional information

  • The server does not crash (panic is recovered and surfaced as internal error), but the export always fails.
  • Checked duplicates: #8484 (modump execute error, closed) and #13681 (result_scan union empty, closed) are different symptoms.

Activity

  1. added
    kind/bug
    severity/s1
    on Oct 19, 2026
  2. added and removed
    severity/s1
    on Oct 19, 2026
  3. added this to the MO-202610 milestone on Oct 19, 2026
  4. Ariznawlll commented on Oct 19, 2026

    @Ariznawlll
    CollaboratorAuthor

    Refined trigger condition

    The panic fires specifically on the first file rotation (when the output exceeds max_file_size and the exporter tries to open the second split file):

    • max_file_size 1 with an ~1.6KB result → the first split file split.csv (1020 bytes ≈ 1KB, 5 rows) IS written, then the rotation to file integrate mysql parser from pingcap #2 hits errgroup.WithContext(nil) and panics.

    So the first split chunk is produced correctly; the nil-context panic occurs on openNewFile for the subsequent chunk. This narrows the fix to the per-rotation openNewFile call (the ctx/reqCtx is nil only on the rotation path, not the initial open).

  5. removed their assignment
    on Oct 22, 2026
  6. Ariznawlll commented on Oct 22, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main;测试日期:2026-10-22。
    • 实际测试 commit:75ae9a79d626622e6ccec0bcb28412f5fcf84c7f,是该轮执行时核对的官方 main;发布评论时 main 已前进,本评论不声称测试过后续提交。
    • 修复 PR #30641 已 MERGED;merge commit 9f7fe43649b3eb9e34f1bc4073ecbc03c6e2a2a3 已核实位于上述测试 SHA 的祖先链。
    • 隔离 macOS arm64 部署:2 CN / 1 TN / 1 LogService,DISK-V2;本场景经公共 TCP 连接一个 CN,不宣称跨 CN 故障恢复验证。
    • 实际 mo-service 构建信息 vcs.revision 与上述 SHA 一致,运行时 git_version 为 75ae9a7。工作树受跟踪源码无差异,但含其他未跟踪 QA 文件,build info 为 vcs.modified=true;不是官方发布二进制。

    原问题验证

    保存实际查询结果并动态获取 query ID;2048 行,每行包含唯一 id、200 字符文本及 DATE。执行 MODUMP QUERY_RESULT ... MAX_FILE_SIZE 1,连续 3/3 轮完成,实际产生至少两个文件,无首次轮转 panic。逐文件 CSV 解析并与独立构造的全部 2048 条预期记录比较,无缺失、重复或错值。

    Happy Path 覆盖

    1. 不分片参数 MAX_FILE_SIZE 100000 生成恰好一个文件,同样逐行核对全部 2048 条记录通过。
    2. result_scan 行数为 2048;原表行数 2048、id 合计 2098176,完整文本和日期均未变。

    Unhappy Path 覆盖

    1. 使用全零 UUID 请求不存在的保存结果,返回 MySQL 错误;未产生任何 invalid.csv 分片。
    2. 错误后源表全量数据保持一致,SELECT 1 正常;清理后临时文件目录和测试数据库均不存在,连接关闭。

    白盒验证

    本次新增回归不导入 MatrixOne 内部源码,不用内部 mock 替代产品路径;通过实际服务的 SQL/客户端协议及导出文件断言。本次 MOTR 迁移验证未新增或重跑内部 Go/race 测试。

    回归测试

    已提交独立 MOTR PR #258,head e8a012246457624f7091c44f6d3445a4ebab1f48;从官方 MOTR main 建立,不追加 #247,也没有新建 MO 仓库 PR。该回归 PR 目前 OPEN,未声称已合入。

    • 固定版本场景代码。
    • 正常 MOTR runner 定向执行两套场景,各重复 3 次:total=6 / success=6 / failed=0 / skipped=0。本 issue 对应场景为 3/3,不把同组其他场景累计成它的次数。
    • 离线框架测试 431 项通过;这是测试框架/oracle 验证,不是 431 项产品验收。
    • 未执行完整 MOTR 产品 suite、完整 14_issue_regression suite、Linux/TKE 验证或修复前二进制对照。
    • CI run 39767106305 的四个 job 在任何步骤开始前被 Actions budget 阻止,steps 为空。CI 未执行,不记为通过,也不记为产品失败。

    测试证据

    本地原始日志:/tmp/mo-seven-qa-jc6Q4H/motr-migration-final.log,最终汇总 total=6 success=6 failed=0 skipped=0、耗时 13.00s,任务自有服务退出码 0。离线日志:motr-migration-offline.log。本地文件不是已上传的 GitHub artifact;可公开检查的测试实现见上述固定版本链接及 PR。

    本结论限定为上述 main SHA 的本 issue 原问题及所列边界;不代表 4.2 发布线、完整集成 CI 或所有分布式场景已通过。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions