Repository navigation
Closed
matrixorigin/mo_dump
#58Labels
area/compatibilitykind/compatibilityThe compatibility with mysql 8.0 should be discussed further.priority/p2Low priority feature that should be implemented in this version
Description
环境:MatrixOne 8.0.30-MatrixOne-v4.2.5(arm64/linux)。
现象:mo-dump -csv 的产物无法跨机器/跨目录恢复
-csv 模式下,mo-dump 把数据写入本地 CSV 文件,并在 SQL 脚本里用 导出时的绝对路径 引用它:
LOAD DATA LOCAL INFILE '/tmp/csvout/spt_s.csv' INTO TABLE `s`
FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' PARALLEL 'FALSE';因此恢复能否成功,取决于原机器上那个绝对路径是否仍然存在:
| 场景 | 结果 |
|---|---|
在原路径所在机器恢复,CSV 仍在 /tmp/csvout/ |
✅ 成功(3 行、2MB 大值完整) |
| 从另一个目录执行该 dump(CSV 仍在原绝对路径) | ✅ 成功(绝对路径仍命中) |
| CSV 已移动/删除后恢复 | ❌ ERROR 2 (HY000) at line 15: File '/tmp/csvout/spt_s.csv' not found (OS errno 2 - No such file or directory) |
| 换一台机器恢复(CSV 一并拷过去,但路径不同) | ❌ 同上(脚本里写的是旧机器的绝对路径,需先人工改写) |
客户端未开 --local-infile |
❌ ERROR 2068 (HY000) at line 15: LOAD DATA LOCAL INFILE file request rejected due to restrictions on access. |
影响
- 逻辑备份不可搬迁:备份的目的是"出事了能在别处恢复"。
-csv的 dump 只有在恢复机上的绝对路径与导出机完全一致时才可用 —— 跨机器、跨目录、容器化恢复都需要先对脚本做路径改写,属于容易在演练时才暴露的坑。 - 两个文件必须成对保管:
.sql脚本 + 同名 CSV 文件;只保留.sql会得到一个"看起来完整但无法恢复"的备份(与恢复时才报ERROR 2)。 - 默认(非
-csv)模式没有这个问题 —— 数据以INSERT语句写在 dump 内,无外部文件依赖,实测向量列 / BLOB / 2MB 大值 / 特殊字符全部逐行一致。
复现
docker run -d --name mo -p 6001:6001 matrixorigin/matrixone:latest
mysql -h127.0.0.1 -P6001 -uroot -p111 -e "create database t1; create table t1.s(id int primary key, t text); insert into t1.s values (1,'a');"
mo-dump -u root -p 111 -h 127.0.0.1 -P 6001 -db t1 -csv > d.sql # 生成 t1_s.csv(当前目录)
grep 'LOAD DATA' d.sql # 里面是绝对路径
mysql --local-infile=1 -h127.0.0.1 -P6001 -uroot -p111 < d.sql # 同机同路径 → 成功
mv t1_s.csv /tmp/; mysql --local-infile=1 -h127.0.0.1 -P6001 -uroot -p111 < d.sql # → ERROR 2建议
- 导出时写相对路径(相对 dump 文件所在目录),或提供一个参数让用户指定输出路径的写法(如
-csv-dir/ 相对模式);这样"把 .sql 与 .csv 放在同一目录"即可恢复,符合备份的直觉; - 若短期保持绝对路径,建议:
- 在文档中显著说明
-csv的 dump 依赖绝对路径、需连同 CSV 一起搬迁并改写路径; - 在 dump 文件头部加注释说明这一依赖;
- 在文档中显著说明
- 客户端侧要求(必须
--local-infile=1)建议一并在文档写明,否则首次恢复会直接撞ERROR 2068; - 文档中可明确推荐:需要可搬迁的逻辑备份时使用默认模式(
INSERT,无外部文件依赖),-csv仅用于需要 CSV 数据文件本身的场景。
关联
- 同一 CSV 路径下的数据正确性问题另见
matrixorigin/mo_dump:Some improvements for MAX/MIN #44(含反斜杠文本反斜杠翻倍)、Make use of as many SIMD registers as possible #45(BLOB/二进制被替换为 U+FFFD) mo_dumpFix MIN: avx512 version of VPCMPEQQ has changed behavior #43:含生成列的表导出后无法恢复- 本仓库 [Compatibility]: MySQL 8 的 mysqldump 无法从 MatrixOne 导出(SET SESSION information_schema_stats_expiry 报 'the system variable is global') #30473:MySQL 8 的
mysqldump无法从 MatrixOne 导出(标准工具链缺口;mo-dump是其可用替代)
Metadata
Metadata
Assignees
Labels
area/compatibilitykind/compatibilityThe compatibility with mysql 8.0 should be discussed further.priority/p2Low priority feature that should be implemented in this version
Activity
slyunnn commentedon Oct 27, 2026
Regression and extended verification for #30481 (2026-10-27)
Verification Environment
main:802376360c574f44aea23db5eef3cfcebf0527fd—perf: adapt bulk user AUTO_INCREMENT prefetch to observed demand (#31410); freshly built runtimegit_version() = 8023763.mo_dumplatestmain:9f0cc1173a9dc2def2656de3cb5c4b988c879442—Merge pull request #69 from ck89119/issue-30917-main; the testedmo-dumpbinary was built from this checkout.2 CN / 1 TN / 1 LogService / Proxy. Proxy26833, CN127151, and CN227152were reachable. Export and restore used Proxy; restored rows were read through all three endpoints.mo-dumpand MySQL CLI over TCP using the MySQL wire protocol; CSV restore used--local-infile=1.What Was Covered
-csvexport generatedLOAD DATA LOCAL INFILEwith a relative CSV filename, not the export-time absolute path.3rows matched the original lengths andMD5digests, including a2,097,152-byteLONGTEXTvalue and comma-containing text.LOCAL INFILEdisabled, the load failed withERROR 2068. Running from a directory without the relative CSV file failed withERROR 2.-local-infile=falsestill emitted an absolute server-sideLOAD DATA INFILEpath. The default non-CSV SQL export had no CSV dependency and restored the same rows withLOCAL INFILEdisabled.Findings
The portable LOCAL CSV path was implemented in merged mo_dump PR #58, merge commit
d9d6375512620f12ff371b8602cc1d10d6f6caa0. Relative filenames are resolved from the importing client's current working directory, so run the restore from the directory containing the CSV files or otherwise arrange the path accordingly.MOTR / BVT Coverage
No MOTR case was added: this scenario requires the external
mo-dumpclient, filesystem relocation and MySQLLOCAL INFILE, and was exercised end-to-end here. The full BVT suite was not rerun.Final Conclusion
Fixed for the reported cross-directory
LOCAL INFILErestore on the pinnedmo_dumpand MatrixOnemaincommits. A large-value regression is warranted because the original report included a large field and the client must transfer it; this run covered one2 MiBvalue. High row counts are not needed for this path-resolution issue.