Repository navigation
Description
Description
mo-dump SQL mode emits two consecutive INSERT INTO headers when a single row exceeds its default 1 MiB -net-buffer-length. The command exits 0 and prints MODUMP SUCCESS, but the generated backup is invalid SQL and cannot restore the row.
Environment
- MatrixOne branch:
main; fixed test commit:7c146f4adbf068dd0c06b377157cfb7d7698b1eb(2026-10-20) - mo-dump
main:324c33dbdc7075cd5d7beaafd1e15c76709dd442 - Isolated local LOG/TN/CN, SQL port 6001; no shared cluster or customer data.
Steps to reproduce
CREATE DATABASE dump_large_src;
CREATE TABLE dump_large_src.t(id INT PRIMARY KEY, payload LONGTEXT);
INSERT INTO dump_large_src.t VALUES (1, REPEAT('x', 1049000));
SELECT id, LENGTH(payload) FROM dump_large_src.t; -- 1, 1049000
CREATE DATABASE dump_large_dst;mo-dump -u root -db dump_large_src -tbl t > dump.sql
mysql --binary-mode=1 -D dump_large_dst < dump.sqlThe connection flags/credentials should be adapted to the test cluster. -tbl t intentionally produces a table-only script, so the destination database is created separately.
Actual behavior
mo-dump exits 0 and appends MODUMP SUCCESS. The SQL contains two consecutive headers for one row:
INSERT INTO `t` VALUES INSERT INTO `t` VALUES (1, '...')Import fails with ERROR 1064 (42000) near the second INSERT INTO; the destination table has zero rows. The source still has exactly one row of length 1,049,000, and a subsequent SELECT 1 succeeds.
Expected behavior
An export with a valid supported LONGTEXT row should produce a restorable SQL statement independent of the configured output buffer. If export cannot represent the row, it must fail explicitly instead of writing MODUMP SUCCESS.
Stability and controls
- Reproducer: 3/3 independent new source/destination databases, all export exit 0, each dump has exactly two
INSERT INTOheaders, all imports fail with 1064, each destination remains empty. - The same 1,049,000-byte row with
-net-buffer-length 2097152imports successfully and compares equal in both directions for every column. - The same row exported with
-csvimports successfully with exact byte-for-byte payload equality. - A separate 1,000-byte row with the default buffer imports successfully and compares equal.
- No original table was modified by the failing imports.
Evidence
Local isolated artifacts: large_row_a.sql, large_row_b.sql, large_row_c.sql, large_row_buf2m.sql, small_row.sql, and large_csv_ctrl/dump.sql under /private/tmp/mo-dump-cont-20261020.o75VwQ/. In all three failing scripts, the INSERT header occurs twice. The passing controls returned forward_mismatch=0 and reverse_mismatch=0 in a per-column source/target comparison.
Code analysis
In cmd/mo-dump/main.go showInsert, the outer loop writes the INSERT INTO prefix before checking whether the pending row exceeds netBufferLength. On that overflow path, curBuf remains pending and the loop continues without resetting buf; the next iteration writes the prefix a second time before appending the row. This matches both the duplicate header and the fact that raising the buffer size fixes the export. The exporter success marker does not validate that the generated SQL is restorable.
Regression coverage
After a fix, add a mo-dump SQL round-trip test for rows just below, exactly at, and above netBufferLength, including a single oversized LOB and a following normal row. Assert one valid header per INSERT, exact restored bytes and row count, and correct nonzero exit if writing fails. No repository test or PR was added during this exploratory run.
Related
- No matching open/closed issue was found in
matrixorigin/matrixoneormatrixorigin/mo_dumpusing large-row,net-buffer-length, and repeated-INSERT searches. - [Bug]: excessive non-cache off-heap residency during streaming mo-dump (4GiB export uses ~7.8GiB) #30575 concerns streaming memory residency; [Bug]: mo-dump reports success after export query is canceled and silently omits rows #30574 concerns canceled source queries, not this SQL buffer rollover.
- The MySQL compatibility contract does not define this
mo-dumpoutput behavior.
Activity
Ariznawlll commentedon Oct 21, 2026
Independent reproduction + scope extension (v3.x @
b24d1b3, 2026-10-21, macOS arm64): the same double-header corruption reproduces with LONGBLOB (not just LONGTEXT), at 5 MiB:Byte-level:
);\nINSERT INTOlVALUES INSERT INTOlVALUES (1,'yyyy...— two headers, no separator, in-file successor statement corrupted. Partial restore confirmed: earlier table in the same dump (a 64 KB BLOB row) did restore before the failure — the DROP DATABASE at the top had already run, so the target DB is left partially loaded.Additional classifier data from the same sweep (all consistent with MySQL, for the record):
BLOBrejects at exactly 65,536 bytes with "Src length 65536 is larger than Dest length 65535" — 65,535 accepted. Correct MySQL BLOB cap, clean error.MEDIUMBLOB/LONGBLOB/MEDIUMTEXTDDL all accepted; LONGBLOB stores/retrieves 5 MiB fine via SQL (5242880 length verified). So the engine handles large blobs; only the dump path corrupts them.This makes the blast radius: any schema using LONGBLOB/LONGTEXT columns ≥ net-buffer-length gives silent-unrestorable backups, and the multi-table dump leaves earlier tables restored while the offending one is dropped/empty.
Ariznawlll commentedon Oct 23, 2026
测试版本
main。1393cb552456adb1b84041ca07a215baed494efc,隔离干净源码和实际二进制嵌入 SHA /vcs.modified=false/ 运行时git_version()一致。首次在2b388dd1690f83e2e807d6809180336dae2a68eb的 3/3 通过后 main 推进,关闭前门槛拦截了写入;重建后又完整执行 3/3,以下次数以最终重测计,不累加冒充覆盖。f228f16e97644a148e820f2c283e93fd177ec618,实际二进制完整 VCS 和干净源码一致。已读原问题、研发补充的 5 MiB LONGBLOB 场景、修复 #62 完整 diff/review。修复已 MERGED,merge0ed6f92e4b30cabe935e7025229201265fd7bc38在被测工具 SHA 祖先链中;不是在未合入版本提前转测。原问题验证
按正文创建
t(id INT PRIMARY KEY,payload LONGTEXT)的等价 UUID 隔离库表,插入(1,REPEAT('x',1049000)),使用默认 1 MiB 缓冲、-tbl表级 SQL 导出,再恢复到独立预建目标库。连续 3/3:导出退出 0、有成功标记,无
VALUES INSERT INTO重复头;真实恢复退出 0。恢复后唯一一行id=1、payload 完整等于 1,049,000 个x,不是只比较 LENGTH/COUNT。源数据保持不变。相同回归换用修复前工具,3/3 捕获原始表的重复 INSERT 头,且每次失败后库清理复核通过。Happy Path 覆盖
buffer-1、buffer、buffer+1,在 1,024 / 1,048,576 bytes 两个缓冲阈值各测三种情况,每种 3/3 恢复全值一致。00FF275C0A二进制(含非法 UTF-8/NUL/引号/反斜杠/LF)、SQL NULL、空 bytes。SHOW COLUMNS元数据,不接受只恢复前一张表的部分结果。Unhappy Path 覆盖
-where表达式,各 3/3 非零退出且不输出MODUMP SUCCESS;失败前后目标原始表完整不变,所有源表保持一致。SELECT 1仍正常。不把输出中断后的半份文件视为可恢复备份。白盒验证
go test -count=3 ./cmd/mo-dump通过,0.822s。首次漏传项目 CGo 库链接配置,编译阶段报library 'mo' not found,尚未进入测试;补齐 Makefile 等价 CGo 参数后通过,不算产品失败。Test_showInsertOversizedRow、TestShowInsertRows、TestShowInsertScanError、TestDumpExitStatus、TestGenOutputUnfinishedRows执行-race -count=3,通过,4.895s;覆盖既有缓冲清理、迭代/扫描错误及退出状态契约。没有新增 MO Go PR。324c33dbdc7075cd5d7beaafd1e15c76709dd442同一用例 3/3 在原始表重复头断言处失败(恢复前拦截,当时 MO 服务为2b388dd1690f83e2e807d6809180336dae2a68eb);不是假称旧版恢复成功。旧构建未嵌入 VCS 字段,来源由干净源码、直接构建记录及 SHA256916712249f18de50fb5ce24a7499536cc364523c63aa74f9ad3a3804f17171cb绑定,明确区别于新工具已核实的嵌入 SHA。回归测试
13a6aad987e93be1883daa54f08a63d4cc5fe5a2起分支,head462a1730c70c94e2c7f80fe65fa657de43e0085e,Open draft;未追加 select without from clause is not supported #247,未修改其他人的 PR。issue_30638_modump_large_rows.py+ 手写配对.out+ 五项离线契约。显式启用MOTR_MODUMP_TESTS=1和工具路径,最新 SHA 定向--repeat 33/3 PASS、零 skip、12.43s。未配置工具时跳过,不把 skip 当产品覆盖。14_issue_regression/MOTR、对象存储、跨主机/分布式恢复、并发源 DML、崩溃恢复或性能基准。测试证据
/tmp/mo-remaining-yvQVzl/motr-latest.log、service-latest.log、motr-final.log(首次 SHA)、framework.log、baseline.log、old-0.stderr至old-2.stderr、service.log、service-old.log;分别保留每轮 MOTR 判定、完整离线框架、旧版重复头断言与清理记录。30afadcfc3c704f7671f8430d6252956651c1972373901d2be629da2e6a4d8ee,与当前固定值一致;未跳过校验或修改源码。最终构建完成后才执行重测。/tmp/mo-hourly-0408-r3IOMR/old-build.log。测试结论
测试通过。