Skip to content

[Bug]: mo-dump CSV reports success for valid 12 MiB row but generated LOAD DATA cannot restore it #30640

Closed

Description

@Ariznawlll

Description

mo-dump -csv reports a successful backup for an existing, valid 12 MiB LONGTEXT row, but the generated LOAD DATA LOCAL INFILE script cannot restore it. The client receives ERROR 2013: Lost connection to MySQL server during query; the target table exists but contains zero rows. Raising the client's max_allowed_packet to 64 MiB does not help.

Environment

  • MatrixOne main test commit: 7c146f4adbf068dd0c06b377157cfb7d7698b1eb (2026-10-20)
  • mo-dump main: 324c33dbdc7075cd5d7beaafd1e15c76709dd442
  • Isolated local LOG/TN/CN, SQL port 6001, synthetic rows only.

Steps to reproduce

CREATE DATABASE dump_csv_big_src;
CREATE TABLE dump_csv_big_src.t(id INT PRIMARY KEY, payload LONGTEXT);
INSERT INTO dump_csv_big_src.t VALUES (1, REPEAT('x', 12582912));
SELECT COUNT(*), LENGTH(MAX(payload)) FROM dump_csv_big_src.t;
-- 1, 12582912
CREATE DATABASE dump_csv_big_dst;
mo-dump -u root -db dump_csv_big_src -tbl t -csv > dump.sql
mysql --binary-mode=1 --local-infile=1 --max-allowed-packet=67108864 \
  -D dump_csv_big_dst < dump.sql

Connection parameters and test-only credentials should be adapted to the local instance. The generated script contains CREATE TABLE followed by LOAD DATA LOCAL INFILE for its CSV file.

Actual behavior

  • Export exits 0, writes a 12 MiB CSV file and MODUMP SUCCESS.
  • Import exits 1 with ERROR 2013 (HY000) ... Lost connection to MySQL server during query at the generated LOAD DATA LOCAL INFILE line.
  • Destination table has zero rows. Source row remains one row/12,582,912 bytes with unchanged MD5, and a new SELECT 1 succeeds.
  • Replacing LOCAL with server-side LOAD DATA INFILE against the same CSV file gives a clearer ERROR 20101: size of row cannot exceed the max value of txn-entry-size-limit; it still cannot restore the backup.

Expected behavior

A supported row that already exists in MatrixOne should not yield a successful CSV backup that cannot be restored. Either the generated CSV restore path must support the row, or export must reject this mode with a clear, nonzero error before reporting success. LOCAL must surface a normal error rather than abruptly disconnecting the client.

Stability and controls

  • Three independent fresh CSV exports and target databases: 3/3 exports exited 0; 3/3 imports returned 2013; 3/3 targets remained empty while the source remained intact and new connections worked.
  • Separate fresh 4 MiB, 8 MiB and 9 MiB LONGTEXT CSV exports/imports all passed, with source and target compared column-by-column and no mismatches.
  • The same 12 MiB source row exported in SQL mode with -net-buffer-length 16777216, then imported with a 64 MiB client packet setting, passed exact bidirectional column comparison. Thus the value is valid and the failure is specific to CSV/LOAD.
  • MEDIUMTEXT accepted 16,777,215 bytes; 16,777,216 bytes was rejected with 1406 without changing the original row. A 32 MiB row across MEDIUMTEXT/LONGTEXT likewise exports as CSV but cannot be reloaded.

Evidence

Synthetic files and output logs are retained under /private/tmp/mo-dump-cont-20261020.o75VwQ/, including blob12_d_csv, blob12_e_csv, blob12_f_csv, their generated SQL/CSV files, and the passing 9 MiB CSV and 12 MiB SQL controls. The three 12 MiB target checks each showed count 0; source showed count 1, length 12,582,912, MD5 2ceb1d3adc7ff97c138acfa4d440d9c0, followed by SELECT 1.

Code analysis

pkg/config/configuration.go defines LargestEntryLimit = 10 * 1024 * 1024. pkg/sql/util/csvparser/csv_parser.go readUntil returns an internal error when its accumulated buffer exceeds that limit. That explains the server-side rejection and why a 9 MiB control passes. mo-dump cmd/mo-dump/main.go emits CSV and a LOAD DATA LOCAL INFILE script without checking whether any row can be reloaded under that limit. The abrupt LOCAL client disconnect requires separate frontend/protocol investigation; this is an observed symptom, not yet a proven root cause.

Regression coverage

After the product decision/fix, test CSV export→generated LOCAL restore just below and above the loader's row limit, plus a LONGTEXT value accepted by SQL INSERT. Assert a restorable dump or an explicit nonzero export error, exact bytes/count, normal error delivery without connection loss, and target/source state after failure. No repository test or PR was added during this exploratory run.

Related

Activity

  1. added this to the MO-202610 milestone on Oct 20, 2026
  2. added
    kind/bug
    on Oct 20, 2026
  3. added theissue type on Oct 20, 2026
  4. 22 remaining items

  5. assigned and unassigned on Oct 27, 2026
  6. Ariznawlll commented on Oct 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 官方 main f847803802289b2b2d0df4f0a2f842c2804b823a,修复 #31300 的 merge commit 533e95796177d9eacdc909059ccf72b7ddd3ba5f 位于祖先链。
    • 2026-10-28;macOS/arm64、隔离 1 CN + 1 TN + 1 Log;服务二进制 VCS revision 与上述 SHA 一致。mo-dump 官方 main 9f0cc1173a9dc2def2656de3cb5c4b988c879442,真实 mysql 客户端开启 LOCAL 和 64 MiB packet。

    原问题验证

    源表 LONGTEXT 12,582,912 字节,真实 mo-dump -csv 生成 SQL 与 CSV,再用 mysql 执行生成的 LOAD DATA LOCAL INFILE,3 个独立目标库 3/3 导出、恢复成功;每轮目标行数 1、长度 12,582,912,MD5 069e5676af785a0c995cfd9671e8f823 与源表一致。源表操作后未变化。

    Happy Path 覆盖

    MOTR 独立 3 轮同时覆盖 12 MiB 原场景和 9 MiB 对照;每轮源、目标逐行比较 ID、长度、MD5,均一致,临时 CSV 和测试数据库清理成功。

    Unhappy Path 覆盖

    在默认 64 MiB record 限制下,65 MiB LOCAL CSV 3/3 返回 20301,包含 exceeds max record size 67108864,目标表行数保持 0,同一连接随后 SELECT 1 返回 1;不再表现为客户端 2013 断连。每轮均确认清理测试库。

    白盒验证

    本轮是实际导出程序、mysql 客户端与服务端的黑盒往返,未新增 Go UT/race。未单独模拟网络中断和其它非默认大小限制。

    回归测试

    MOTR #284 issue_30640_mo_dump_large_csv.py 覆盖原 12 MiB、9 MiB 对照、65 MiB 拒绝及连接复用,定向 3/3。此场景需显式提供 mo-dump 和 mysql 二进制;未配置时跳过,不把跳过当通过。完整 MOTR suite 未运行。

    测试证据

    修复 PR CI 的 UT、SCA、PROXY、PESSIMISTIC BVT、Coverage 通过;MOTR 新 head CI 在发布时尚未报告,不能声明完整 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

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions