Repository navigation
Description
Description
SELECT ... INTO OUTFILE FORMAT 'jsonline' exports VARBINARY/BLOB as Base64 JSON strings, but MatrixOne's LOAD DATA INFILE ... format='jsonline', jsondata='object' loads those strings literally into the original binary columns. The export and import both report success while bytes change. This is an internal export→import data-correctness failure, not a MySQL compatibility claim.
Environment
- Branch: official
main - MatrixOne commit:
7c146f4adbf068dd0c06b377157cfb7d7698b1eb - mo-dump commit (independent control only):
324c33dbdc7075cd5d7beaafd1e15c76709dd442 - Deployment: isolated local standalone, 1 CN / 1 TN / 1 LOG, SQL on 127.0.0.1:6001; 2026-10-20
Steps to reproduce
Use a fresh, writable local file path for every run (replace the /tmp/... paths if needed):
CREATE DATABASE qa_outfile_binary;
CREATE TABLE qa_outfile_binary.src (id INT PRIMARY KEY, raw VARBINARY(16));
INSERT INTO qa_outfile_binary.src VALUES (1, X'00FF'), (2, X'AB00'), (3, NULL);
SELECT id, HEX(raw) FROM qa_outfile_binary.src ORDER BY id;
SELECT id, raw FROM qa_outfile_binary.src ORDER BY id
INTO OUTFILE '/tmp/qa_outfile_binary_1.jsonl' FORMAT 'jsonline';
CREATE TABLE qa_outfile_binary.dst LIKE qa_outfile_binary.src;
LOAD DATA INFILE {
'filepath'='/tmp/qa_outfile_binary_1.jsonl',
'format'='jsonline',
'jsondata'='object'
} INTO TABLE qa_outfile_binary.dst;
SELECT id, HEX(raw) FROM qa_outfile_binary.dst ORDER BY id;The generated JSONL lines for the non-NULL rows contain "raw":"AP8=" and "raw":"qwA=".
Actual behavior
Both statements succeed. Source bytes are 00FF, AB00, NULL; restored bytes are 4150383D (AP8=), 7177413D (qwA=), NULL. Row count and IDs remain 3 and 1/2/3, so count-only validation misses the corruption. A BLOB control changes 00FF to 4150383D as well.
Expected behavior
MatrixOne's own JSONLINE export and JSONLINE load should round-trip binary columns exactly, or reject the incompatible load/export path explicitly before reporting successful restoration. It must not silently replace binary payloads with their Base64 text representation.
Stability and controls
- Reproducer: 3/3 independent JSONL export files and fresh destination tables, each with exact wrong bytes above.
- Controls: the same source
VARBINARYrows round-trip exactly throughSELECT ... INTO OUTFILE FORMAT 'csv'+LOAD DATA LOCAL INFILE(00FF,AB00, NULL), and throughFORMAT 'parquet'+ ParquetLOAD DATA INFILEwith the same exact values. A separate scalar/JSON/NULL table round-tripped exactly through JSONLINE. - Source remained
00FF/AB00/NULL after all runs; connectionSELECT 1succeeded. This is not an exporter setup, file-path, or general loader failure.
Evidence
The minimal SQL and exact output above are independently reproducible. Local test artifacts and a run checkpoint are under /private/tmp/mo-dump-cont-20261020.o75VwQ/outfile_1020 and /private/tmp/mo-dump-cont-20261020.o75VwQ/continuation.md; these are local evidence locations, not public download links.
Code analysis
pkg/frontend/export.go:1386-1388:vectorValueToJSONexplicitly Base64-encodesBINARY,VARBINARY, andBLOB.pkg/sql/plan/build_ddl.go:8463-8471: the writable-external-table binder already rejects these types for JSONLINE and comments that the JSONLINE reader does not decode Base64. TheSELECT INTO OUTFILEpath does not apply an equivalent compatibility guard.- This code explains the observed mismatch; the direct SQL reproducer, not the source comment alone, establishes the user-visible bug.
Regression coverage
Add a SQL-level export→load round-trip for BINARY/VARBINARY/BLOB with NUL and non-UTF-8 bytes, plus NULL and text/Parquet controls; assert exact HEX values and explicit failure if the path remains unsupported. No repository regression test or PR was added in this exploration turn.
Related
- MatrixOne [Test]: Qualify lossless ecosystem adapters and full Airbyte/NiFi/Kafka Connect recovery pipelines #29848 is a broad ecosystem-adapter test tracker, not this specific JSONLINE export/load corruption.
- mo_dump Make use of as many SIMD registers as possible #45 is a different CSV exporter implementation and error path.
- Checked open/closed MatrixOne issues and PRs for JSONLINE/Base64/BINARY/OUTFILE synonyms and the MySQL compatibility contract; no matching report found.
Activity
fix(external): wrap jsonline binary export as {"$binary":...}; separa…
fix(external): decode base64 on jsonline load for binary columns (#30635
XuPeng-SH commentedon Oct 21, 2026
合入后 QA 复核发现一个旧文件兼容缺口(静态代码路径,当前容器缺 Go/mo-service,未能本地启动集群复跑):这个 issue 记录的旧版 OUTFILE 行是
{"raw":"AP8="},对应原始字节X'00FF'。新jsonLineScalarText只解码{"$binary":"AP8="};裸 JSON 字符串会直接fmt.Sprint(node)并作为文本写入,合入的回归测试也明确断言{"raw":"AP8="}仍得到字节AP8=。因此升级后再 LOAD 旧版 MatrixOne JSONL 归档仍会把00FF还原为 ASCIIAP8=(HEX4150383D),原 issue 的数据往返失败对历史文件仍成立。建议补一个可识别的旧版导出兼容策略(例如显式格式版本/加载选项),同时继续保留手写纯文本的无损导入;请在确认策略后补历史文件回归。Ariznawlll commentedon Oct 22, 2026
测试版本
mainc232b6d2a1b5a94ac624c4954586569841c1e153(执行前与 GitHub 官方 main 核对)9a7ea39bd4a432c454960c9e7296482fec818382已包含在上述 main原问题验证
在同一版本上用原始二进制值
X'00FF'、X'AB00'、NULL比较两条路径,每条重复 3 轮:SELECT id,raw ... INTO OUTFILE ... FORMAT 'jsonline'生成{"raw":{"$binary":"AP8="}}等包装对象,再LOAD DATA INFILE ... format='jsonline', jsondata='object':3/3 轮均恢复HEX(raw)=00FF, AB00, NULL,与源表逐值一致。{"id":1,"raw":"AP8="}、{"id":2,"raw":"qwA="}、{"id":3,"raw":null})在同一最新版 main 上加载:3/3 轮 SQL 均报告成功,但实际HEX(raw)=4150383D, 7177413D, NULL,前两项是 Base64 文本的 ASCII 字节,不是原字节00FF, AB00。因此新版导出往返已修复,历史 MatrixOne JSONL 归档路径仍会静默损坏;这与 issue 中的原始旧文件复现一致,不能据新版路径通过而关闭整个问题。执行命令:
go test ./pkg/tests/issues -run '^TestIssue30635PublicSQLCurrentAndLegacyJSONL$' -count=1 -v -timeout=10m。该独立 QA 探针内部对原始/当前路径各运行 3 轮,使用隔离 worktree 的临时测试文件,未提交产品仓库。三轮实际输出均为:Happy Path 覆盖
VARBINARY两种含 NUL/非 UTF-8 字节及 NULL:3/3 精确一致;源表保持不变,三轮后清理表和数据库成功。pkg/sql/colexec/external中的包装BINARY/VARBINARY/BLOB、对象/数组、普通文本透传、非二进制列等定向 Go 测试在该 SHA 上-count=3通过。Unhappy Path 覆盖
$binaryBase64 对象/数组均要求报错,不将其静默解释为文本;-count=3通过。\\N的边界按非 NULL 保留,原始\\N和 JSON null 按 NULL 处理;定向 Go 用例-count=3通过。白盒验证
pkg/sql/colexec/external/reader_csv_projection_test.go中TestJsonLineBinaryBase64Roundtrip明确将旧版裸"AP8="的期望设为字符串AP8=,因此现有测试证明新格式设计选择,但不能证明旧 MatrixOne 归档恢复正确。本轮没有运行-race;该问题是确定性的值错误,不是并发竞态。回归测试
-count=3通过,但旧版文件在该回归中被断言为错误的 ASCII 字节,尚无历史兼容修复/回归。测试证据
HEX实际输出;源码回归、PR 和 CI 链接见上,可用报告中的两条 JSONL 行独立重放。测试结论
测试不通过。
fix: recover legacy JSONLINE and retire locks on CN shutdown (#30832)
XuPeng-SH commentedon Oct 23, 2026
合并后 QA 跟进 — PR #30832
PR #30832 已于 2026-10-23 合并,merge commit
5fe68a88e48ae115856b18deaeecc4953101a0be(head6bd96852121915fd2a03e0b1c85bbfb4f46b72cb)。其变更在 JSONLINE 读取端新增显式json_binary='legacy_base64',仅对 BINARY/VARBINARY/BLOB 的裸 Base64 字符串解码;默认文本语义不变,包装格式仍可读。PR review 报告了 reader/planner 定向测试及 JSONLINE SQL 用例通过;这是 review 的测试记录,本轮没有在本地独立运行。该实现覆盖了本 issue 记录的旧版裸 Base64 归档恢复路径,建议由 Ariznawlll 在合并后的 main 上复核该选项端到端恢复
00FF/AB00、NULL 和默认纯文本控制。Issue 保持 open,待独立验收后再决定关闭。XuPeng-SH commentedon Oct 23, 2026
QA follow-up on PR #29554 head
9cf7b6922192ea4d3158d1954a9af2c36fd2fca8(2026-10-23), with a baseline correction: the pre-merge first-parent head9d4e8b3130hasisJsonNullSentinel(valN)in both JSONLINE object and array paths; base5fb586e1does not. The merge resolution drops this first-parent behavior. Current head returnscsvparser.Field{Val: val}without settingIsNull, andgetColDatausesfield.IsNullto append SQL NULL, so a raw JSON string equal to"\\N"is no longer marked NULL after LOAD. This is static code comparison only; I did not run local Go tests or a MatrixOne server.I submitted REQUEST_CHANGES on PR #29554 for this first-parent regression and added a PR comment correcting my earlier baseline wording. Please restore the raw-node sentinel decision for both object and array paths and cover JSON NULL plus a
$binarypayload decoding to bytes5C4E(which must remain non-NULL).Ariznawlll commentedon Oct 24, 2026
测试版本
main;commit:6fb6531432aaec8c1fbd98a30364941559e0e1d6。执行前核对官方 main;运行二进制的 Go 构建元数据vcs.revision为相同完整 SHA,隔离 worktree 已跟踪源码无改动。5fe68a88e48ae115856b18deaeecc4953101a0be是上述 main 的祖先。原问题验证
原始
VARBINARY/BLOB数据两行分别为00FF/AB00、AB00/00FF,另有 NULL 行。当前版本SELECT ... INTO OUTFILE FORMAT 'jsonline'再默认LOAD DATA INFILE,3/3 轮目标逐值等于源表:00FF/AB00、AB00/00FF、NULL/NULL,不是 Base64 文本的 ASCII 字节。旧版 MatrixOne 裸 Base64 JSONLINE 形状也独立复核:对
"AP8="/"qwA="、"qwA="/"AP8="、NULL 使用显式json_binary='legacy_base64'读取,3/3 轮恢复为相同的原始字节和 NULL;源表保持 3 行不变。Happy Path 覆盖
00FF/AB00、AB00/00FF、NULL/NULL;MOTR 阶段还用 SQL 生成相同旧文件形状,并在每轮清除 stage 文件和数据库。AP8=、qwA=仍作为普通文本写入,实际 HEX 为4150383D、7177413D;这是明确选项的正常文本对照,不是把这些错字节写成历史恢复成功 golden。Unhappy Path 覆盖
!!,3/3 均返回 ERROR 20301;拒绝后的目标表计数为 0,源表仍为 3 行,无部分导入。白盒验证
本次以公开 SQL 和实际文件/stage 验收字节值,未新增 Go UT/-race;没有以只检查行数或 Go 单元测试替代二进制值比较。
回归测试
已在 MOTR PR #278 head
4f5a55f9199bba02d27973f52d45341747f2b293增加issue_30635_jsonline_binary_legacy_roundtrip.test/.result;定向 3/3、99/99 条语句通过,完整 suite 中本用例也通过。完整14_issue_regressionsuite 为 669 成功、22 失败、34 跳过(725 总计);失败是其他具名用例,不宣称全绿。PR 离线检查 四项通过;本 head 的线上 MatrixOne 集成 CI 未运行。测试证据
/private/tmp/mo-qa-30681-30650-30635-DafFfy/validate_three.py,三轮输出含准确 HEX、默认文本对照与非法载荷拒绝。测试结论
测试通过。